-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinitBoundaries.m
90 lines (70 loc) · 2.44 KB
/
initBoundaries.m
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
function [PosBoundary, VelBoundary, Rho_RhoHalf_dRhoBoundary] = initBoundaries(boxWidth, boxHeight, h, enableBottomWall, enableSideWalls, enableTopWall, rho0 )
%initBoundaries
minX = -2*h;
maxX = boxWidth + 2*h;
numParticlesPerColumn = size(minX:h:maxX,2); % From -2*h:h:boxWidth+2*h
numParticlesPerRow = size(h:h:boxHeight-h,2); % From h:h:(boxHeight-h)
totalNumBoundaryParticles = 0;
if(enableBottomWall)
totalNumBoundaryParticles = totalNumBoundaryParticles + 3*numParticlesPerColumn;
end
if(enableSideWalls)
totalNumBoundaryParticles = totalNumBoundaryParticles + 6*numParticlesPerRow;
end
if(enableTopWall)
totalNumBoundaryParticles = totalNumBoundaryParticles + 3*numParticlesPerColumn;
end
PosBoundary = zeros(2, totalNumBoundaryParticles);
VelBoundary = zeros(2, totalNumBoundaryParticles);
Rho_RhoHalf_dRhoBoundary = zeros(3, totalNumBoundaryParticles);
Rho_RhoHalf_dRhoBoundary(1:2,:) = rho0;
counter = 1;
if(enableBottomWall)
for x = minX:h:maxX
PosBoundary(1,counter) = x;
PosBoundary(2,counter) = 0;
counter = counter + 1;
PosBoundary(1,counter) = x;
PosBoundary(2,counter) = -h;
counter = counter + 1;
PosBoundary(1,counter) = x;
PosBoundary(2,counter) = -2*h;
counter = counter + 1;
end
end
if(enableSideWalls)
for y = h:h:boxHeight-h
PosBoundary(1,counter) = minX;
PosBoundary(2,counter) = y;
counter = counter + 1;
PosBoundary(1,counter) = minX+h;
PosBoundary(2,counter) = y;
counter = counter + 1;
PosBoundary(1,counter) = 0;
PosBoundary(2,counter) = y;
counter = counter + 1;
PosBoundary(1,counter) = boxWidth;
PosBoundary(2,counter) = y;
counter = counter + 1;
PosBoundary(1,counter) = boxWidth+h;
PosBoundary(2,counter) = y;
counter = counter + 1;
PosBoundary(1,counter) = maxX;
PosBoundary(2,counter) = y;
counter = counter + 1;
end
end
if(enableTopWall)
for x = minX:h:maxX
PosBoundary(1,counter) = x;
PosBoundary(2,counter) = boxHeight;
counter = counter + 1;
PosBoundary(1,counter) = x;
PosBoundary(2,counter) = boxHeight+h;
counter = counter + 1;
PosBoundary(1,counter) = x;
PosBoundary(2,counter) = boxHeight+2*h;
counter = counter + 1;
end
end
end