

p1 = newp;
firstp = p1;
line = newl;
firstline = line;
loop = newll;
surf = news;
lref = 1.00000;

///////////////////////////
 
Point(p1+  1)={  0.1000,  0.0000,  0.0000, lref};
Point(p1+  2)={  0.1000,  0.0000,  0.0210, lref};
Point(p1+  3)={  0.1000,  0.0000,  0.0310, lref};
Point(p1+  4)={  0.1000,  0.0000,  0.0600, lref};
Point(p1+  5)={  0.1000,  0.0000, -0.0210, lref};
Point(p1+  6)={  0.1000,  0.0000, -0.0310, lref};
Point(p1+  7)={  0.1000,  0.0000, -0.0600, lref};
Point(p1+  8)={  0.0631,  0.0000,  0.0000, lref};
Point(p1+  9)={  0.1000,  0.0210,  0.0000, lref};
Point(p1+ 10)={  0.1000,  0.0310,  0.0000, lref};
Point(p1+ 11)={  0.1000,  0.0600,  0.0000, lref};
Point(p1+ 12)={  0.1000, -0.0210,  0.0000, lref};
Point(p1+ 13)={  0.1000, -0.0310,  0.0000, lref};
Point(p1+ 14)={  0.1000, -0.0600,  0.0000, lref};
 
// circle r=r1
Circle(line+  1)={p1+       2,p1+       1,p1+  9};
Circle(line+  2)={p1+       9,p1+       1,p1+  5};
Circle(line+  3)={p1+       5,p1+       1,p1+ 12};
Circle(line+  4)={p1+      12,p1+       1,p1+  2};

// circle r=r2
Circle(line+  5)={p1+       3,p1+       1,p1+ 10};
Circle(line+  6)={p1+      10,p1+       1,p1+  6};
Circle(line+  7)={p1+       6,p1+       1,p1+ 13};
Circle(line+  8)={p1+      13,p1+       1,p1+  3};

// circle r=rbox
Circle(line+  9)={p1+       4,p1+       1,p1+ 11};
Circle(line+ 10)={p1+      11,p1+       1,p1+  7};
Circle(line+ 11)={p1+       7,p1+       1,p1+ 14};
Circle(line+ 12)={p1+      14,p1+       1,p1+  4};
/////////////////////

Line(line+ 38)={p1+  1,p1+  2};
Line(line+ 39)={p1+  2,p1+  3};
Line(line+ 40)={p1+  3,p1+  4};
Line(line+ 41)={p1+  1,p1+  9};
Line(line+ 42)={p1+  9,p1+ 10};
Line(line+ 43)={p1+ 10,p1+ 11};
Line(line+ 44)={p1+  1,p1+  5};
Line(line+ 45)={p1+  5,p1+  6};
Line(line+ 46)={p1+  6,p1+  7};
Line(line+ 47)={p1+  1,p1+ 12};
Line(line+ 48)={p1+ 12,p1+ 13};
Line(line+ 49)={p1+ 13,p1+ 14};

 
line = line-1;
 
// channel exit surfaces
Line Loop(loop+1) = {line+9, -line-40, -line-5, line+49};
Plane Surface(surf+1) = {loop+1};
Line Loop(loop+2) = {line+8, -line-49, -line-4, line+46};
Plane Surface(surf+2) = {loop+2};
Line Loop(loop+3) = {line+7, -line-46, -line-3, line+43};
Plane Surface(surf+3) = {loop+3};
Line Loop(loop+4) = {line+6, -line-43, -line-2, line+40};
Plane Surface(surf+4) = {loop+4};

// solid surfaces internal to channel
Line Loop(loop+5) = {line+5, -line-39, line+48};
Plane Surface(surf+5) = {loop+5};
Line Loop(loop+6) = {line+4, -line-48, line+45};
Plane Surface(surf+6) = {loop+6};
Line Loop(loop+7) = {line+3, -line-45, line+42};
Plane Surface(surf+7) = {loop+7};
Line Loop(loop+8) = {line+2, -line-42, line+39};
Plane Surface(surf+8) = {loop+8};

// solid surfaces external to channel
Line Loop(loop+9) = {line+13, -line-41, -line-9, line+50};
Plane Surface(surf+9) = {loop+9};
Line Loop(loop+10) = {line+12, -line-50, -line-8, line+47};
Plane Surface(surf+10) = {loop+10};
Line Loop(loop+11) = {line+11, -line-47, -line-7, line+44};
Plane Surface(surf+11) = {loop+11};
Line Loop(loop+12) = {line+10, -line-44, -line-6, line+41};
Plane Surface(surf+12) = {loop+12};
 
//+
Extrude {-0.1, 0, 0} {
  Line{10}; Line{13}; Line{12}; Line{11}; 
}

/////////////////////////////
//// END OF THRUSTER BOX ////
/////////////////////////////

p1 = newp;
firstp = p1;
line = newl;
firstline = line;
loop = newll;
surf = news;
lref = 1.00000;
xo = 0.0;
xf = 2.5;
wp = 4.0;
wp1= 1.0;
hff1 = 1.0;
hff2 = 1.5;

///////////////////////////
 
Point(p1+  1)={  xo, -wp1, 0.0, lref};
Point(p1+  2)={  xo, -wp1, -hff1, lref};
Point(p1+  3)={  xo, -wp1-hff1, 0.0, lref};
Point(p1+  4)={  xo, -wp1,  hff1, lref};

Point(p1+  5)={  xo, wp, 0.0, lref};
Point(p1+  6)={  xo, wp, -hff1, lref};
Point(p1+  7)={  xo, wp+hff1, 0.0, lref};
Point(p1+  8)={  xo, wp,  hff1, lref};

Point(p1+  9) ={  xf, -wp1, 0.0, lref};
Point(p1+  10)={  xf, -wp1, -hff2, lref};
Point(p1+  11)={  xf, -wp1-hff2, 0.0, lref};
Point(p1+  12)={  xf, -wp1,  hff2, lref};

Point(p1+  13)={  xf, wp, 0.0, lref};
Point(p1+  14)={  xf, wp, -hff2, lref};
Point(p1+  15)={  xf, wp+hff2, 0.0, lref};
Point(p1+  16)={  xf, wp,  hff2, lref};


Line(line+ 1)={p1+  4,p1+  8};
Line(line+ 2)={p1+  2,p1+  6};
Line(line+ 3)={p1+  12,p1+  16};
Line(line+ 4)={p1+  10,p1+  14};

Line(line+ 5)={p1+  4,p1+  12};
Line(line+ 6)={p1+  3,p1+  11};
Line(line+ 7)={p1+  2,p1+  10};

Line(line+ 8)={p1+  8,p1+  16};
Line(line+ 9)={p1+  7,p1+  15};
Line(line+ 10)={p1+  6,p1+  14};

Circle(line+ 11)={p1+      2,p1+       1,p1+  3};
Circle(line+ 12)={p1+      3,p1+       1,p1+  4};
Circle(line+ 13)={p1+      6,p1+       5,p1+  7};
Circle(line+ 14)={p1+      7,p1+       5,p1+  8};

Circle(line+ 15)={p1+      14,p1+       13,p1+  15};
Circle(line+ 16)={p1+      15,p1+       13,p1+  16};
Circle(line+ 17)={p1+      10,p1+       9,p1+  11};
Circle(line+ 18)={p1+      11,p1+       9,p1+  12};

//////////////////////////
//// END OF FAR FIELD ////
//////////////////////////

p1 = newp;
firstp = p1;
line = newl;
firstline = line;
loop = newll;
surf = news;
dp = 0.5;
zp = -0.1;
xp = 1.0;

Point(p1+  1)={  xp, -wp1, zp, lref};
Point(p1+  2)={  xp,  wp, zp, lref};
Point(p1+  3)={  xp+dp,  wp, zp, lref};
Point(p1+  4)={  xp+dp, -wp1, zp, lref};

Point(p1+  5)={  xp, -wp1, zp-0.01, lref};
Point(p1+  6)={  xp,  wp, zp-0.01, lref};
Point(p1+  7)={  xp+dp,  wp, zp-0.01, lref};
Point(p1+  8)={  xp+dp, -wp1, zp-0.01, lref};

Line(line+ 1)={p1+  1,p1+  2};
Line(line+ 2)={p1+  2,p1+  3};
Line(line+ 3)={p1+  3,p1+  4};
Line(line+ 4)={p1+  4,p1+  1};

Line(line+ 5)={p1+  5,p1+  6};
Line(line+ 6)={p1+  6,p1+  7};
Line(line+ 7)={p1+  7,p1+  8};
Line(line+ 8)={p1+  8,p1+  5};

Line(line+ 9) ={p1+  1,p1+  5};
Line(line+ 10)={p1+  2,p1+  6};
Line(line+ 11)={p1+  3,p1+  7};
Line(line+ 12)={p1+  4,p1+  8};

//////////////////////////////////////////////////

//+
Line Loop(14) = {68, -81, -80, -69, 78, 79};
//+
Line Loop(15) = {55, 51, 63, 59};
//+
Plane Surface(67) = {14, 15};
//+
Line Loop(16) = {70, -83, -82, -71, 84, 85};
//+
Plane Surface(68) = {16};
//+
Line Loop(17) = {68, 75, -70, -72};
//+
Plane Surface(69) = {17};
//+
Line Loop(18) = {69, 77, -71, -74};
//+
Plane Surface(70) = {18};
//+
Line Loop(19) = {72, -85, -73, 79};
//+
Surface(71) = {19};
//+
Line Loop(20) = {73, -84, -74, 78};
//+
Surface(72) = {20};
//+
Line Loop(21) = {75, -83, -76, 81};
//+
Surface(73) = {21};
//+
Line Loop(22) = {82, -76, -80, 77};
//+
Surface(74) = {22};
//+
Line Loop(23) = {87, 88, 89, 90};
//+
Plane Surface(75) = {23};
//+
Line Loop(24) = {91, 92, 93, 94};
//+
Plane Surface(76) = {24};
//+
Line Loop(25) = {88, 97, -92, -96};
//+
Plane Surface(77) = {25};
//+
Line Loop(26) = {89, 98, -93, -97};
//+
Plane Surface(78) = {26};
//+
Line Loop(27) = {87, 96, -91, -95};
//+
Plane Surface(79) = {27};
//+
Line Loop(28) = {90, 95, -94, -98};
//+
Plane Surface(80) = {28};
//+
Physical Surface(10) = {73, 69, 71, 72, 70, 74, 68};
//+
Physical Surface(20) = {67, 54, 58, 62, 66, 11, 10, 13, 12, 8, 7, 6, 9};
//+
Physical Surface(30) = {5, 2, 3, 4};
//+
Physical Surface(40) = {75};
//+
Physical Surface(50) = {76, 79, 78, 77, 80};

Surface Loop(1) = {69, 67, 73, 68, 74, 70, 72, 71, 62, 11, 10, 58, 54, 13, 12, 66, 4, 3, 2, 5, 9, 8, 7, 6};
Surface Loop(2) = {75, 79, 77, 78, 80, 76};

Volume(1) = {1, 2};

tmp[] = Physical Surface {40,50};

Rotate {{0, 1, 0}, {1.25, 0.0, -0.1}, Pi/6} {
  Surface { tmp[] }; 
}



