-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeometry_2d.template_geo
182 lines (147 loc) · 4.93 KB
/
geometry_2d.template_geo
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
jet_positions[] = {2.6, -2.6}; // Always need to be ordered
DefineConstant[
length = {2.2, Name "Channel length"}
front_distance = {0.2, Name "Cylinder center distance to inlet"}
bottom_distance = {0.2, Name "Cylinder center distance from bottom"}
jet_radius = {0.05, Name "Cylinder radius"}
jet_width = {10*Pi/180, Name "Jet width in radians"}
width = {0.41, Name "Channel width"}
cylinder_size = {0.02, Name "Mesh size on cylinder"}
box_size = {0.05, Name "Mesh size on wall"}
coarse_size = {0.1, Name "Mesh size close to the outflow"}
coarse_distance = {0.5, Name "Distance from the cylinder where coarsening starts"}
];
// Seed the cylinder
center = newp;
Point(center) = {0, 0, 0, cylinder_size};
n = #jet_positions[];
radius = jet_radius;
If(n > 0)
cylinder[] = {};
lower_bound[] = {};
uppper_bound[] = {};
// Define jet surfaces
For i In {0:(n-1)}
angle = jet_positions[i];
x = radius*Cos(angle-jet_width/2);
y = radius*Sin(angle-jet_width/2);
p = newp;
Point(p) = {x, y, 0, cylinder_size};
lower_bound[] += {p};
x0 = radius*Cos(angle);
y0 = radius*Sin(angle);
arch_center = newp;
Point(arch_center) = {x0, y0, 0, cylinder_size};
x = radius*Cos(angle+jet_width/2);
y = radius*Sin(angle+jet_width/2);
q = newp;
Point(q) = {x, y, 0, cylinder_size};
upper_bound[] += {q};
// Draw the piece; p to angle
l = newl;
Circle(l) = {p, center, arch_center};
// Let each yet be marked as a different surface
Physical Line(5+i) = {l};
cylinder[] += {l};
// Draw the piece; angle to q
l = newl;
Circle(l) = {arch_center, center, q};
// Let each yet be marked as a different surface
Physical Line(5+i) += {l};
cylinder[] += {l};
EndFor
// Fill in the rest of the cylinder. These are no slip surfaces
lower_bound[] += {lower_bound[0]};
Physical Line(4) = {}; // No slip cylinder surfaces
For i In {0:(n-1)}
p = upper_bound[i];
q = lower_bound[i+1];
pc[] = Point{p}; // Get coordinates
qc[] = Point{q}; // Get coordinates
// Compute the angle
angle_p = Atan2(pc[1], pc[0]);
angle_p = (angle_p > 0) ? angle_p : (2*Pi + angle_p);
angle_q = Atan2(qc[1], qc[0]);
angle_q = (angle_q > 0) ? angle_q : (2*Pi + angle_q);
angle = angle_q - angle_p; // front back
angle = (angle < 0) ? angle + 2*Pi : angle; // check also back front
Printf("%g", angle);
// Greter than Pi, then we need to insert point
If(angle > Pi)
half[] = Rotate {{0, 0, 1}, {0, 0, 0}, angle/2} {Duplicata{Point{p};}};
l = newl;
Circle(l) = {p, center, half};
// Let each yet be marked as a different surface
Physical Line(4) += {l};
cylinder[] += {l};
l = newl;
Circle(l) = {half, center, q};
// Let each yet be marked as a different surface
Physical Line(4) += {l};
cylinder[] += {l};
Else
l = newl;
Circle(l) = {p, center, q};
// Let each yet be marked as a different surface
Physical Line(4) += {l};
cylinder[] += {l};
EndIf
EndFor
// Just the circle
Else
p = newp;
Point(p) = {-jet_radius, 0, 0, cylinder_size};
Point(p+1) = {0, jet_radius, 0, cylinder_size};
Point(p+2) = {jet_radius, 0, 0, cylinder_size};
Point(p+3) = {0, -jet_radius, 0, cylinder_size};
l = newl;
Circle(l) = {p, center, p+1};
Circle(l+1) = {p+1, center, p+2};
Circle(l+2) = {p+2, center, p+3};
Circle(l+3) = {p+3, center, p};
cylinder[] = {l, l+1, l+2, l+3};
Physical Line(4) = {cylinder[]};
EndIf
// The chanel
p = newp;
Point(p) = {-front_distance, -bottom_distance, 0, box_size};
Point(p+1) = {jet_radius+coarse_distance, -bottom_distance, 0, coarse_size};
Point(p+2) = {-front_distance+length, -bottom_distance, 0, coarse_size};
Point(p+5) = {-front_distance, -bottom_distance+width, 0, box_size};
Point(p+4) = {jet_radius+coarse_distance, -bottom_distance+width, 0, coarse_size};
Point(p+3) = {-front_distance+length, -bottom_distance+width, 0, coarse_size};
l = newl;
// A no slip wall
Line(l) = {p, p+1};
Line(l+1) = {p+1, p+2};
Physical Line(1) = {l, l+1};
// Outflow
Line(l+2) = {p+2, p+3};
Physical Line(2) = {l+2};
// Top no slip wall
Line(l+3) = {p+3, p+4};
Line(l+4) = {p+4, p+5};
Physical Line(1) += {l+3, l+4};
// Inlet
Line(l+5) = {p+5, p};
Physical Line(3) = {l+5};
// Coarse line
Line(l+6) = {p+1, p+4};
coarse = newll;
Line Loop(coarse) = {(l+1), (l+2), (l+3), -(l+6)};
s = news;
Plane Surface(s) = {coarse};
Physical Surface(1) = {s};
// The one with cylinder
cframe[] = {l, (l+6), l+4, l+5};
// // The surface to be mesh;
outer = newll;
Line Loop(outer) = {cframe[]};
inner = newll;
Line Loop(inner) = {cylinder[]};
s = news;
Plane Surface(s) = {inner, outer};
Physical Surface(1) += {s};
//Characteristic Length{cylinder[]} = cylinder_size;
//Characteristic Length{coarse[]} = coarse_size;
//Characteristic Length{cframe[]} = box_size;