Code covered by the BSD License

# Meshing thin shells using four noded elements

### Siva Srinivas Kolukula (view profile)

To mesh thin shells using four noded elements to use in Finite Element Analysis

```function [coordinates,nodes] = MeshConicalShell(Radius,theta,Height,NT,NR)
% To Mesh a Conical Shell with 4 and 3 noded Elements
%--------------------------------------------------------------------------
% Code written by : Siva Srinivas Kolukula                                |
%                   Senior Research Fellow                                |
%                   Structural Mechanics Laboratory                       |
%                   Indira Gandhi Center for Atomic Research              |
%                   India                                                 |
% E-mail : allwayzitzme@gmail.com                                         |
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
% Purpose:
%         To Mesh a Conical Shell to use in FEM Analysis
% Variable Description:
% Input:
%           theta - Angle of the sector to which Cone needed
%           Height - Height of the cone
%           NR - Number of Elements along Radius (Number of Rings)
%           NT - Number of Angular sectors
% Output:
%           coordinates - The nodal coordinates of the mesh
%           -----> coordinates = [node X Y]
%           nodes - The nodal connectivity of the elements
%           -----> nodes = [element node1 node2......]
% NOTE : If the node number repeats take it as Triangular Element
%--------------------------------------------------------------------------
nel = NR*NT ;           % Total Number of Elements in the Mesh
nnel = 4 ;              % Number of nodes per Element
% Number of points on the Radius and Angluar discretization
npT = NT+1 ;
npR = NR+1 ;
nnode = npT*npR ;       % Total number of nodes
% Discretizing the Length and Breadth of the plate
nT = linspace(0,theta,npT)*pi/180 ;
[T R] = meshgrid(nT,nR) ;
% Convert grid to cartesian coordintes
XX = R.*cos(T) ;
YY = R.*sin(T) ;
ZZ = m*R ;
% surf(XX,YY,ZZ) ;
% axis equal
% To get the Nodal Connectivity Matrix
coordinates = [XX(:) YY(:) ZZ(:)] ;
NodeNo = 1:nnode ;
nodes = zeros(nel,nnel) ;
%
if npR==npT
NodeNo = reshape(NodeNo,npT,npR);
nodes(:,1) = reshape(NodeNo(1:npR-1,1:npT-1),nel,1);
nodes(:,2) = reshape(NodeNo(2:npR,1:npT-1),nel,1);
nodes(:,3) = reshape(NodeNo(2:npR,2:npT),nel,1);
nodes(:,4) = reshape(NodeNo(1:npR-1,2:npT),nel,1);
% If the elements along the circumference and radius are different
else%if npR>npT
NodeNo = reshape(NodeNo,npR,npT);
nodes(:,1) = reshape(NodeNo(1:npR-1,1:npT-1),nel,1);
nodes(:,2) = reshape(NodeNo(2:npR,1:npT-1),nel,1);
nodes(:,3) = reshape(NodeNo(2:npR,2:npT),nel,1);
nodes(:,4) = reshape(NodeNo(1:npR-1,2:npT),nel,1);
end
%
% Plotting the Finite Element Mesh
% Initialization of the required matrices
X = zeros(nnel,nel) ;
Y = zeros(nnel,nel) ;
Z = zeros(nnel,nel) ;
% Extract X,Y coordinates for the (iel)-th element
for iel = 1:nel
X(:,iel) = coordinates(nodes(iel,:),1) ;
Y(:,iel) = coordinates(nodes(iel,:),2) ;
Z(:,iel) = coordinates(nodes(iel,:),3) ;
end
% Figure
fh = figure ;
set(fh,'name','Preprocessing for FEA','numbertitle','off','color','w') ;
fill3(X,Y,Z,'w','FaceAlpha',1) ;
title('Finite Element Mesh of thin Conical shell','HandleVisibility','off') ;