You are on page 1of 1

function [A,Ae,P,E,T,GDOF,X,Y]=My2dMesh(xc,yc,r,s)

%Creates 2d Linear Triangular Mesh from given Outer Boundary and Inner
%Excavation Boundary.The Output variables are A,Ae,P,E,T,X,Y. where;
%A = Total Area of the Model.
%Ae = Area of Triangular Elements.
%P = Point Marix of Nodes.
%E = Boundary Edges of the Model
%T = Element Connectivity Matrix of Triangular Meshes.
%GDOF = Global Degree of Freedim.
%X,Y = Coordinates of Element Connectivity Matrix.
%[A,Ae,P,E,T,GDOF,X,Y] =My2dMesh(0,0,2,10); creates model Square of size 10
%unites whose opening is at center(0,0) with radius 2 unit.
model = createpde;
R1 = [3,4,-s,s,s,-s,-s,-s,s,s]'; % Defining Boundary (Square)
C1 = [1,xc,yc,r]'; %Defining Excavation (Circle)
C1 = [C1;zeros(length(R1)-length(C1),1)];
GM = [R1,C1];
SF = 'R1-C1';
NS = char('R1','C1');
NS = NS';
G = decsg(GM,SF,NS);
geometryFromEdges(model,G);
% pdegplot(model, 'EdgeLabels','on');
% axis equal;
% hold on;
Triang_Mesh = generateMesh(model,'Hgrad',1.5,'Hmax',1/5,'GeometricOrder','linear',
'jiggle','on', 'jiggleiter',10);
pdemesh(model)%,'NodeLabels','on')
xlim([-2*s,2*s]);
ylim([-2*s,2*s]);
[A,Ae]=area(Triang_Mesh);
[P,E,T] = meshToPet(Triang_Mesh);
GDOF= zeros(6,size(T,2));
for i = 1:3
X(i,:) = P(1,T(i,:)); %X-Ordinate of Nod(i)
Y(i,:) = P(2,T(i,:)); %Y_Ordinate of Nod(i)
GDOF(2*i-1,:) = T(i,:)*2-1;
GDOF(2*i,:) = T(i,:)*2;
end

end

You might also like