area_with_hole.m 1.17 KB
Newer Older
Andreas Zilian's avatar
Andreas Zilian committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
%% Example Mesh
% create a rectangle geometry with hole and mesh
clear all; addpath([ '..' filesep '..' filesep ]);

n = 10; % n = number of grid nodes per side

% create all geo points
gp1 = mgen.MgGeoPoint( [-1, -1] );
gp2 = mgen.MgGeoPoint( [ 1, -1] );
gp3 = mgen.MgGeoPoint( [ 1,  1] );
gp4 = mgen.MgGeoPoint( [-1,  1] );
% center point
gcenter = mgen.MgGeoPoint([0.,0.]);
% create all geo lines
gl1  = mgen.MgGeoLine2Point( [gp1, gp2], n );
gl2  = mgen.MgGeoLine2Point( [gp2, gp3], n );
gl3  = mgen.MgGeoLine2Point( [gp3, gp4], n );
gl4  = mgen.MgGeoLine2Point( [gp4, gp1], n );
% number of ring => refine near the circle
a = 0.4;
b = 0.8;
c = 0.0; % ellipse rotation angle in rad
% refinement
normFunc = mgen.MgNormFunction( mgen.MgNormFunctionType.Quadratic);
% create area
ga1  = mgen.MgGeoArea4LineEllipsoidalVoid([gl1,gl2,gl3,gl4], 10, a, b, c, normFunc);
% create geo object and generate the mesh
geo = mgen.MgGeo( [gp1, gp2, gp3, gp4], ...
                  [gl1, gl2, gl3, gl4], ...
                  [ga1] );
% print geo and mesh data info
% fprintf(geo.print());
% plot mesh
cla; clf;
fig = figure(1); subplot('Position',[0.05 0.05 0.90 0.90]); axis equal; hold on;
geo.plot();