
// 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 parameter file --------------------------------- //

Include "Vortex_Shaking_Fazilleau_1_parameters.geo" ;

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

// Mesher options :
//  - We ask to save the mesh in a binary file (lightweight)
//  - We use ExpertMode so that Gmsh won't complain for mixed
//    structured-unstructured mesh
//  - We call the MeshAdapt algorithm and optimize its result
Mesh.Algorithm     = 2 ;
Mesh.Binary        = 1 ;
Mesh.Optimize      = 1 ;
General.ExpertMode = 1 ;

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

// Building the superconductor. ------------------------------------ //

xs = SupraThick / 2. ;
ys = SupraWidth / 2. ;

ps = newp ;
Point( ps   ) = { -xs , -ys , 0. } ;
Point( ps+1 ) = {  xs , -ys , 0. } ;
Point( ps+2 ) = {  xs ,  ys , 0. } ;
Point( ps+3 ) = { -xs ,  ys , 0. } ;
ls = newl ; 
Line( ls   ) = { ps   , ps+1 } ;
Line( ls+1 ) = { ps+1 , ps+2 } ;
Line( ls+2 ) = { ps+2 , ps+3 } ;
Line( ls+3 ) = { ps+3 , ps   } ;
lls = newll ;
Line Loop( lls ) = { ls:ls+3 } ;
ss = news ;
Plane Surface( ss ) = { lls } ;

Transfinite Line{ ls   , -(ls+2) } = ( SupraThickDivs + 1 ) ;
Transfinite Line{ ls+1 , -(ls+3) } =
  ( SupraWidthDivs + 1 ) Using Bump ( 1. / SupraEdgeAttraction ) ;
Transfinite Surface{ ss };
Recombine Surface { ss };

// Building the air enclosure. ------------------------------------- //

xya = BboxInnerSize / 2. ;
lca = ( BboxOuterSize - BboxInnerSize ) / ( 5. * AirMeshDens ) ;

pa = newp ;
Point( pa   ) = { -xya , -xya , 0. , lca } ;
Point( pa+1 ) = {  xya , -xya , 0. , lca } ;
Point( pa+2 ) = {  xya ,  xya , 0. , lca } ;
Point( pa+3 ) = { -xya ,  xya , 0. , lca } ;
la = newl ; 
Line( la   ) = { pa   , pa+1 } ;
Line( la+1 ) = { pa+1 , pa+2 } ;
Line( la+2 ) = { pa+2 , pa+3 } ;
Line( la+3 ) = { pa+3 , pa   } ;
lla = newll ;
Line Loop( lla ) = { la:la+3 } ;
sa = news ;
Plane Surface( sa ) = { lla , lls } ;

// Building the infinite domain. This one is made out of 4 differents
// sectors (top, right, bottom, left) in order to later use a RectShell
// transformation turning them into a virtually infinite space. ---- //

xyi = BboxOuterSize / 2. ;
lci = lca ;

pi = newp ;
Point( pi   ) = { -xyi , -xyi , 0. , lci } ;
Point( pi+1 ) = {  xyi , -xyi , 0. , lci } ;
Point( pi+2 ) = {  xyi ,  xyi , 0. , lci } ;
Point( pi+3 ) = { -xyi ,  xyi , 0. , lci } ;
li = newl ; 
Line( li   ) = { pa   , pi   } ;
Line( li+1 ) = { pi   , pi+1 } ;
Line( li+2 ) = { pa+1 , pi+1 } ;
Line( li+3 ) = { pi+1 , pi+2 } ;
Line( li+4 ) = { pa+2 , pi+2 } ;
Line( li+5 ) = { pi+2 , pi+3 } ;
Line( li+6 ) = { pa+3 , pi+3 } ;
Line( li+7 ) = { pi+3 , pi   } ;
lli = newll ;
Line Loop( lli   ) = { li   , li+1 , -(li+2) , -la     } ;
Line Loop( lli+1 ) = { li+2 , li+3 , -(li+4) , -(la+1) } ;
Line Loop( lli+2 ) = { li+4 , li+5 , -(li+6) , -(la+2) } ;
Line Loop( lli+3 ) = { li+6 , li+7 , -li     , -(la+3) } ;
si = news ;
Plane Surface( si   ) = { lli   } ;
Plane Surface( si+1 ) = { lli+1 } ;
Plane Surface( si+2 ) = { lli+2 } ;
Plane Surface( si+3 ) = { lli+3 } ;

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

// Tag the physical regions with the IDs defined in the .par file -- //

Physical Surface( SUPRA                  ) = { ss          } ;
Physical    Line( SUPRA_SKIN             ) = { ls:ls+3     } ;
Physical Surface( AIR                    ) = { sa          } ;
Physical Surface( INFINITE_DOMAIN        ) = { si:si+3     } ;
Physical Surface( INFINITE_DOMAIN_BOTTOM ) = { si          } ;
Physical Surface( INFINITE_DOMAIN_RIGHT  ) = { si+1        } ;
Physical Surface( INFINITE_DOMAIN_TOP    ) = { si+2        } ;
Physical Surface( INFINITE_DOMAIN_LEFT   ) = { si+3        } ;
Physical    Line( INFINITY               ) = { li+1:li+7:2 } ;
Physical   Point( CORNER                 ) = { pi          } ;

// ----------------------------------------------------------------- //
//                   ____  _            __                           //
//                  / __ \(_)________  / /___  __  __                //
//                 / / / / / ___/ __ \/ / __ `/ / / /                //
//                / /_/ / (__  ) /_/ / / /_/ / /_/ /                 //
//               /_____/_/____/ .___/_/\__,_/\__, /                  //
//                           /_/            /____/                   //
//                                                                   //
// ----------------------------------------------------------------- //

// Set up some visualization options (for the sake of readability) - //

Include "Vortex_shaking_Fazilleau_1_display.geo" ;
