//Include "solver.geo";

// Define the Geometry
lc=0.8;

// one version : for specifying angles and centres of rotations explicitly
//angle1 = 1.0;
//angle2 = 1.0;
//centre1 = 50.0;
//centre2 = 20.0;

// another version for arcs of the same length
length = 10.0;
ratio = 0.4;
centre1 = 20.0;
centre2 = ratio*centre1;
angle1 = length/centre1;
angle2 = length/centre2;

// centre and points on the circumference
Point(1) = {0, 0, 0, lc};
Point(2) = {1, 0, 0, lc};
Point(3) = {-1, 0, 0, lc};
Point(4) = {0, 1, 0, lc};
Point(5) = {0, -1, 0, lc};

// 4 arcs to form a whole circle
Circle(1) = {2,1,4};
Circle(2) = {4,1,3};
Circle(3) = {3,1,5};
Circle(4) = {5,1,2};

// parent tube
Extrude Line {1, {0.0, 0.0, -5.0}};
Extrude Line {2, {0.0, 0.0, -5.0}};
Extrude Line {3, {0.0, 0.0, -5.0}};
Extrude Line {4, {0.0, 0.0, -5.0}};

// left branch
//Extrude Line {1, {0.0, 1.0, 0.0}, {centre1,0.0,0.0}, angle1};
//Extrude Line {2, {0.0, 1.0, 0.0}, {centre1,0.0,0.0}, angle1};
//Extrude Line {3, {0.0, 1.0, 0.0}, {centre1,0.0,0.0}, angle1};
//Extrude Line {4, {0.0, 1.0, 0.0}, {centre1,0.0,0.0}, angle1};

// right branch
Extrude Line {1, {0.0, -1.0, 0.0}, {-centre2,0.0,0.0}, angle2};
Extrude Line {2, {0.0, -1.0, 0.0}, {-centre2,0.0,0.0}, angle2};
Extrude Line {3, {0.0, -1.0, 0.0}, {-centre2,0.0,0.0}, angle2};
Extrude Line {4, {0.0, -1.0, 0.0}, {-centre2,0.0,0.0}, angle2};

// entry to mother tube
Line Loop(602) ={5,9,13,17};
Plane Surface(603) = {602};

// exit from mother tube into daughters
Line Loop(606) ={1,2,3,4};
Plane Surface(607) = {606};

// exit from left tube
//Line Loop(604) ={21,25,29,33};
//Plane Surface(605) = {604};

// exit from right tube
//Line Loop(600) = {41,37,49,45};
//Plane Surface(601) = {600};
Line Loop(600) ={21,25,29,33};
Plane Surface(601) = {604};

// parent tube volume
Surface Loop(2002) = {603, 8, 12, 16, 20, -607};
Volume(2003) = {2002};

// left daughter volume
//Surface Loop(2004) = {607, 24, 28, 32, 36, 605};
//Volume(2005) = {2004};

// right daughter volume
//Surface Loop(2006) = {607, 40, 44, 48, 52, -601};
//Volume(2007) = {2006};
Surface Loop(2006) = {607, 24, 28, 32, 36, -601};
Volume(2007) = {2006};

// combined volume
//Surface Loop(2000) = {603, 8, 12, 16, 20, 24, 28, 32, 36, 605, 40, 44, 48, 52,601};
//Volume(2001) = {2000};

