// coil.geo: creation of the geometry with GMSH
// 

Include "param.geo";

// Enclosure points
p0 = newp; Point(p0) = {0, 0, 0, 0.5*lc_air};
p1 = newp; Point(p1) = {0, -r_enc, 0, 0.5*lc_air};
p2 = newp; Point(p2) = {r_enc, 0, 0, lc_air};
p3 = newp; Point(p3) = {0, r_enc, 0, 0.5*lc_air};

// Outer shell
p4 = newp; Point(p4) = {0, -r_out, 0, 1.5*lc_air};
p5 = newp; Point(p5) = {r_out, 0, 0, 1.5*lc_air};
p6 = newp; Point(p6) = {0, r_out, 0, 1.5*lc_air};


// First turn points
p7 = newp; Point(p7) = {inner_radius, -width/2, 0, lc_coil};
p8 = newp; Point(p8) = {inner_radius, width/2, 0, lc_coil};
p9 = newp; Point(p9) = {inner_radius+thick, width/2, 0, lc_coil};
p10 = newp; Point(p10) = {inner_radius+thick, -width/2, 0, lc_coil};

// Enclosure lines
L1 = newreg; Circle(L1) = {p1, p0, p2};
L2 = newreg; Circle(L2) = {p2, p0, p3};
L3 = newreg; Line(L3) = {p3, p1};

// Outer shell
L4 = newreg; Line(L4) = {p1, p4};
L5 = newreg; Circle(L5) = {p4, p0, p5};
L6 = newreg; Circle(L6) = {p5, p0, p6};
L7 = newreg; Line(L7) = {p6, p3};


// First turn lines
L8 = newreg; Line(L8) = {p7, p8};
L9 = newreg; Line(L9) = {p8, p9};
L10 = newreg; Line(L10) = {p9, p10};
L11 = newreg; Line(L11) = {p10, p7};

// Line loops
innerBound = newreg; Line Loop(innerBound) = {L1, L2, L3};
outerBound = newreg; Line Loop(outerBound) = {L4, L5, L6, L7, -L2, -L1};
Turn = newreg; Line Loop(Turn) = {L8, L9, L10, L11};

SurfaceOmega_air = newreg; Plane Surface(SurfaceOmega_air) = {innerBound, Turn};
SurfaceOmega_coil = newreg; Plane Surface(SurfaceOmega_coil) = {Turn};
SurfaceOmega_out = newreg; Plane Surface(SurfaceOmega_out) = {outerBound};

Physical Surface(Omega_air) = {SurfaceOmega_air};
Physical Surface(Omega_coil) = {SurfaceOmega_coil};
Physical Surface(Omega_out) = {SurfaceOmega_out};

// For Dirichlet bnd cnd
Physical Line(Gama_D) = {L3, L4, L5, L6, L7};

Mesh.Algorithm = 1;
Mesh.Binary = 1;
//Mesh.SurfaceFaces = 1;
//Mesh.SurfaceNumbers = 1;
//Mesh.LabelType = 2; // Show Phys ID
//Mesh 2;
