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

📄 circular_inclusion.asv

📁 efg code with matlab
💻 ASV
📖 第 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
% For fracture mechanics, the enriched EFG is used. This is a local PUM
% enrichment scheme which has the form:
%
%           u = N_i * u_i + N_j * H(x) * a_j + N_k * (B_i * b_ik)
%  with H(x) / Heaviside function and B_i(x) the branch functions
%  u_i, a_j and B_ik are nodal parameters.

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

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

% Problem: the infinite plate with centered circular inclusion
% The material interface is modeled by abs of the signed distance

% +++++++++++++++++++++++++++++++++++++
%          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 = 10 ;
D = 10 ;

% Material properties

% Matrix
E1  = 1e3 ;
nu1 = 0.3 ;

% Inclusion
E2  = 1e1 ;
nu2 = 0.3 ;

stressState='PLANE_STRAIN';

% Loading
sigmato = 1  ;

% Circular inclusion
r  = 1.0 ;
xc = L/2 ;
yc = D/2 ;

% Inputs special to meshless methods, domain of influence

shape = 'circle' ;         % shape of domain of influence
dmax  = 1.7 ;              % 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'])

% Node density defined by number of nodes along two directions
nnx = 12 ;
nny = 24  ;

% node generation, node is of size (nnode x 2)
% Corner points of the rectangle domain
% Four corner points
pt1 = [0 0] ;
pt2 = [L 0] ;
pt3 = [L D] ;
pt4 = [0 D] ;
node = square_node_array(pt1,pt2,pt3,pt4,nnx,nny);
numnode = size(node,1);

% Define boundaries
% Bottom, right and top edges are imposed by exact displacement

uln = nnx*(nny-1)+1;       % upper left node number
urn = nnx*nny;             % upper right node number
lrn = nnx;                 % lower right node number
lln = 1;                   % lower left node number
cln = nnx*(nny-1)/2+1;     % node number at (0,0)


topEdge  = [ uln:1:(urn-1); (uln+1):1:urn ]';
botEdge  = [ lln:1:(lrn-1); (lln+1):1:lrn ]';

% GET NODES ON DIRICHLET BOUNDARY AND ESSENTIAL BOUNDARY
botNodes  = unique(botEdge);
topNodes  = unique(topEdge);

dispNodes = [botNodes];
tracNodes = topNodes;

% The bottom edge is constrained along Y direction
% The first node of this edge is constrained to X direction
num_disp_nodes = length(dispNodes)+1;
num_trac_nodes = length(tracNodes)  ;

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

deltaX = L/(nnx-1);
deltaY = D/(nny-1);
delta  = max(deltaX,deltaY);
di     = ones(1,numnode)*dmax*delta ;

% +++++++++++++++++++++++++++++++++++++
%            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

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

% Meshing, Q4 elements
inc_u = 1;
inc_v = nnx;
node_pattern = [ 1 2 nnx+2 nnx+1 ];
element = make_elem(node_pattern,nnx-1,nny-1,inc_u,inc_v);

% Building Gauss points
[w,q]=quadrature(6, 'GAUSS', 2 );  % 4x4 Gaussian quadrature for each cell
W = [];
Q = [];
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('Q4',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 ;

% +++++++++++++++++++++++++++++++++++++
%        LEVEL SET INITIALIZATION
%      SELECTION OF ENRICHED NODES
% +++++++++++++++++++++++++++++++++++++


for i = 1 : numnode
    x = node(i,1);
    y = node(i,2);
    d = sqrt((x-xc)^2+(y-yc)^2);
    ls(i)  = d - (r + di(i));
end

enrich_node = find(ls < 0);

% +++++++++++++++++++++++++++++++++++++
%  PLOT NODES,BACKGROUND MESH, GPOINTS
% +++++++++++++++++++++++++++++++++++++
disp([num2str(toc),'   PLOT NODES AND GAUSS POINTS'])
figure
hold on
cntr = plot([0,L,L,0,0],[0,0,D,D,0]);
set(cntr,'LineWidth',3)
h = plot(node(:,1),node(:,2),'bo');
set(h,'MarkerSize',8.5);

theta = -pi:0.1:pi;
x = xc + r*cos(theta);
y = yc + r*sin(theta);
cir = plot(x,y,'k-');
set(cir,'LineWidth',2)

n1 = plot(node(enrich_node,1),node(enrich_node,2),'r*');
set(n1,'MarkerSize',15);
plot(node(dispNodes,1),node(dispNodes,2),'ks');
axis off
axis equal


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

% Initialisation

total_num_node = numnode + size(enrich_node,2)*1  ;
K = sparse(2*total_num_node,2*total_num_node);
f = zeros(2*total_num_node,1);

% Due to the presence of additional dofs, the assembly is a little
% bit difficult than in FEM. We use fictitious nodes to handle these
% additional dofs. At an enriched node, we add one fantom node. These fictitious nodes
% are numbered from the total number of true nodes, ie, from numnode+1 ...

pos = zeros(numnode,1);
nsnode = 0 ;
for i = 1 : numnode
    [snode] = ismember(i,enrich_node);
    if (snode ~= 0)
        pos(i) = (numnode + nsnode*1 ) + 1 ;
        nsnode = nsnode + 1 ;
    end
end


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

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

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

    % For enriched EFG, here is the most important part
    % Nodes within neighbouring of GPs include normal nodes, H enriched
    % nodes and tip enriched nodes
    % ISMEMBER(A,S) for the array A returns an array of the same size as A
    % containing 1 where the elements of A are in the set S and 0 otherwise.

    [snode,s_loc] = ismember(index,enrich_node);
   
    % number of H and tip enriched nodes
    % in index
    num_enr_node = size(find(snode ~= 0),2);
  
    % Scatter of standard part of B matrix
    le   = length(index);
    sctrStdB = zeros(2*le,1);
    sctrStdB(1:2:2*le) = index.*2-1 ; % x displacement
    sctrStdB(2:2:2*le) = index.*2   ; % y displacement

    % No enriched nodes in index
    if (num_enr_node == 0) 
        sctrB = sctrStdB ;
    % There is at least one enriched node in index

⌨️ 快捷键说明

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