/////////////////////
/// GMSH GEOMETRY ///
/////////////////////

/// FILE: dynamic2DHFormulation.geo
/// AUTHOR: Frederic Trillaud <ftrillaudp@gmail.com>
/// UNIVERSITY: UNAM
/// INSTITUTE: IINGEN
/// DATE (english): 02/19/2015
/// UNITS: SI otherwise indicated

/// INTRODUCTION: automatic generation of the geometry to be meshed. Case of the simulation of a solenoid magnet using axial symmetry.


///////////////////////////
/// EXTERNAL PARAMETERS ///
///////////////////////////

Include "parameters.par";


/////////////
/// PRINT ///
/////////////

Printf("wire radius [m]: %g", wireRadius);
Printf("wire surface [m^2]: %g", wireSurface);


//////////////////
/// GEOMETRIES ///
//////////////////

/// Geometry options:
Geometry.Color.Lines = Black;
Geometry.LineWidth = 1;
Geometry.PointSize = 1;

/// Remove duplicate elementary entities allowing to assemble Line Loop() by merging the points defined separately at a same location. To be used upon labelling philosophy.
Coherence;

/// Origin ///
x_0 = 0.; y_0 = 0.; z_0 = 0.;

/// Wire ///
x_1 = wireRadius;      y_1 = 0.;
x_2 = 0.;              y_2 = wireRadius;
x_3 = (-1)*wireRadius; y_3 = 0.;
x_4 = 0.;              y_4 = (-1)*wireRadius;

/// Surroundings of the wire ///
x_5 = infiniteBoundaryInnerRadius;      y_5 = 0.;
x_6 = 0.;                               y_6 = infiniteBoundaryInnerRadius;
x_7 = (-1)*infiniteBoundaryInnerRadius; y_7 = 0.;
x_8 = 0.;                               y_8 = (-1)*infiniteBoundaryInnerRadius;

For i In {1:8}
 z~{i} = 0.;
EndFor

/// List of coordinates:
For i In {0:8}
 x[] += {x~{i}};
 y[] += {y~{i}};
 z[] += {z~{i}};
 n[] += {n~{i}}; // Local length for meshing
EndFor

/// Points ///
For i In {0:8}
 Point(i) = {x[i], y[i], z[i], n[i]};
EndFor

/// Tape ///
Circle(1) = {1, 0, 2};
Circle(2) = {2, 0, 3};
Circle(3) = {3, 0, 4};
Circle(4) = {4, 0, 1};
Line Loop(1) = {1, 2, 3, 4};
Plane Surface(1) = {1};
Physical Surface(wireID) = {1};

/// Surroundings of the wire ///
Circle(5) = {5, 0, 6};
Circle(6) = {6, 0, 7};
Circle(7) = {7, 0, 8};
Circle(8) = {8, 0, 5};
Line Loop(2) = {5, 6, 7, 8};
Plane Surface(2) = {2, 1};
Physical Surface(surroundingID) = {2};


////////////////
/// BOUNDARY ///
////////////////

/// Boundary line on which the boundary condition is applied:
Physical Line(electromagneticBoundaryLineID) = {5, 6, 7, 8};


///////////////
/// MESHING ///
///////////////

/// Color of meshes:
Color Red {Surface {1};} // wire
Color Blue {Surface {2};} // surroundings

/// Remove duplicate nodes of the mesh ///
Coherence Mesh;

// Save mesh as binary file ///
Mesh.Binary = 1;
