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

Include "param.geo";

// Enclosure points
p1 = newp; Point(p1) = {0,-z_enc,0,lc_air/4};
p2 = newp; Point(p2) = {r_enc,-z_enc,0,lc_air};
p3 = newp; Point(p3) = {r_enc,z_enc,0,lc_air};
p4 = newp; Point(p4) = {0,z_enc,0,lc_air/4};

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

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

// First turn lines
L5 = newreg; Line(L5) = {p5,p6};
L6 = newreg; Line(L6) = {p6,p7};
L7 = newreg; Line(L7) = {p7,p8};
L8 = newreg; Line(L8) = {p8,p5};

// Line loops
Bound = newreg; Line Loop(Bound) = {L1,L2,L3,L4};
Turn = newreg; Line Loop(Turn) = {L5,L6,L7,L8};

SurfaceOmega_air = newreg; Plane Surface(SurfaceOmega_air) = {Bound,Turn};
SurfaceOmega_coil = newreg; Plane Surface(SurfaceOmega_coil) = {Turn};

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

// For Dirichlet bnd cnd
Physical Line(Gama_D) = {L1,L2,L3,L4};

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