
// Note : this file contains the definition of the problem geometry.
// To run this example you need to open the .pro file with GetDP.

// ----------------------------------------------------------------- //
//                ____           __          __                      //
//               /  _/___  _____/ /_  ______/ /__  _____             //
//               / // __ \/ ___/ / / / / __  / _ \/ ___/             //
//             _/ // / / / /__/ / /_/ / /_/ /  __(__  )              //
//            /___/_/ /_/\___/_/\__,_/\__,_/\___/____/               //
//                                                                   //
// ----------------------------------------------------------------- //

// Inclusion of the parameters already defined in the .par file
Include "HtsWg_bench1_1e.par";

// ----------------------------------------------------------------- //
//       ____                                  __                    //
//      / __ \____  _________  ____ ___  ___  / /____  __________    //
//     / /_/ / __ `/ ___/ __ `/ __ `__ \/ _ \/ __/ _ \/ ___/ ___/    //
//    / ____/ /_/ / /  / /_/ / / / / / /  __/ /_/  __/ /  (__  )     //
//   /_/    \__,_/_/   \__,_/_/ /_/ /_/\___/\__/\___/_/  /____/      //
//                                                                   //
// ----------------------------------------------------------------- //

// Dimensions for the tape cross-section
DefineConstant[
  TapeWidth = { 12 , Min 2 , Max 12 , Step 2 ,
                Name "Input/1Geometry/1Tape width [mm]" },
  TapeThick = { 0.1 , Min 0.001 , Max TapeWidth , Step 0.1 , 
                Name "Input/1Geometry/2Tape thickness [mm]" },
  MeshDensity = { 5, Min 4 , Max 8 , Step 1 ,
                  Name "Input/1Geometry/3Mesh density",
		  Help Str["Higher numbers drop the size",
		           "of the mesh elements"] }

];
TapeWidth = TapeWidth * mm;
TapeThick = TapeThick * mm;

// Radius for the enclosing region
AirRadius = 10 * mm;

// Typical mesh sizes in the conductor and in the air
TapeMeshSize = TapeThick / MeshDensity;
AirMeshSize = AirRadius / MeshDensity;

// Some visualization options (in the interest of clarity)
Geometry.Color.Lines = Black;
Geometry.LineWidth = 1;
Geometry.PointSize = 1;

// Mesher setup
Mesh.Algorithm = 1;
Mesh.Binary = 1;
Mesh.Optimize = 1;
General.ExpertMode = 1;

// ----------------------------------------------------------------- //
//            ______                          __                     //
//           / ____/__  ____  ____ ___  ___  / /________  __         //
//          / / __/ _ \/ __ \/ __ `__ \/ _ \/ __/ ___/ / / /         //
//         / /_/ /  __/ /_/ / / / / / /  __/ /_/ /  / /_/ /          //
//         \____/\___/\____/_/ /_/ /_/\___/\__/_/   \__, /           //
//                                                 /____/            //
//                                                                   //
// ----------------------------------------------------------------- //

// Definiton of the enclosure points
p0 = newp ; Point(p0) = { 0          , 0          , 0 , AirMeshSize };
p1 = newp ; Point(p1) = { AirRadius  , 0          , 0 , AirMeshSize };
p2 = newp ; Point(p2) = { 0          , AirRadius  , 0 , AirMeshSize };
p3 = newp ; Point(p3) = { -AirRadius , 0          , 0 , AirMeshSize };
p4 = newp ; Point(p4) = { 0          , -AirRadius , 0 , AirMeshSize };

// Establish the 4 circle arcs that limit the surrounding air
l1 = newreg ; Circle(l1) = { p1 , p0 , p2 };
l2 = newreg ; Circle(l2) = { p2 , p0 , p3 };
l3 = newreg ; Circle(l3) = { p3 , p0 , p4 };
l4 = newreg ; Circle(l4) = { p4 , p0 , p1 };
llAir = newreg ; Line Loop(llAir) = { l1 , l2 , l3 , l4 };

// Building a structured mesh for the tape : first we create the lower-
// left corner and then extrude the width and the thickness specifying
// a number of subdivisions
p5 = newp ;
Point(p5) = { -TapeWidth/2 , -TapeThick/2 , 0 , TapeMeshSize };
tp1[]  = Extrude{ TapeWidth , 0 , 0 }
           { Point{p5} ; Layers{(MeshDensity*TapeWidth/TapeThick)} ; };
ttp1[] = Extrude{ 0 , TapeThick , 0 }
           { Line{tp1[1]} ; Layers{MeshDensity} ; Recombine ; };
llTape = newreg; Line Loop(llTape) = {Boundary{Surface{ttp1[1]};}};

sAir = newreg; Plane Surface(sAir) = {llAir, llTape};

// Tag the physical regions with the IDs defined in the .par file
Physical Surface(AIR) = {sAir};
Physical Surface(CONDUCTOR) = {ttp1[1]};
Physical Line(CONDUCTOR_SKIN) = {tp1[1],ttp1[0],ttp1[2],-ttp1[3]};
Physical Line(AIR_LIMIT) = {l1, l2, l3, l4};

// Cohomology computation for the H-Phi formulation, this will be
// used in the .pro file to enforce constraints
Cohomology(1) {AIR, {}};

// Some colors to help read the mesh
Color Red     { Surface{ttp1[1]}; }
Color SkyBlue { Surface{sAir}; }

// Check the mesh coherence
Coherence;
