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] = MeshSphericalShell(Radius,Height,theta,phi,N)
% To Mesh a Spherical 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 Spherical Shell to use in FEM Analysis
% Variable Description:
% Input:
%           Height - Height of the shell
%           theta - Zenith Angle of the shell
%           phi - Polar Angle of the shell
%           N - Number of elements along theta and phi
% 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 = N*N ;                 % Total Number of Elements in the Mesh
nnel = 4 ;                  % Number of nodes per Element
% Number of points in the discretization
npT = N+1 ;
npP = N+1 ;
% Discretizing the theta and phi of the shell
nT = -linspace(0,theta,npT)*pi/180 ;
nP = linspace(0,phi,npP)*pi/180 ;
[T P] = meshgrid(nT,nP) ;
% Convert grid to cartesian coordintes
% mesh(XX,YY,ZZ) ;
% axis equal
% To get the Nodal Connectivity Matrix
coordinates = [XX(:) YY(:) ZZ(:)] ;
nnode = npT*npP ;
NodeNo = 1:nnode ;
nodes = zeros(nel,nnel) ;
%
NodeNo = reshape(NodeNo,npT,npP);
nodes(:,1) = reshape(NodeNo(1:npP-1,1:npT-1),nel,1);
nodes(:,2) = reshape(NodeNo(2:npP,1:npT-1),nel,1);
nodes(:,3) = reshape(NodeNo(2:npP,2:npT),nel,1);
nodes(:,4) = reshape(NodeNo(1:npP-1,2:npT),nel,1);
%
% 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,Z 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 Spherical shell','HandleVisibility','off') ;