/*
copyright (c) 2008-2019, RaghuNath (RaNa) (raghu.elec@gmail.com)
this file and 20191121193103.geo are useful for creating the geometry of the motor on a 2d/3d region.
script created automatically on 20191121193103 from scilab 5.5.2, x64 version using rlib version 6
created for gmsh, 64 bit version
*/
//  ____/\\\\\\\\\_____________________/\\\\\_____/\\\________________........
//  .__/\\\///////\\\__________________\/\\\\\\___\/\\\________________.......
//  .._\/\\\_____\/\\\__________________\/\\\/\\\__\/\\\________________......
//  ..._\/\\\\\\\\\\\/_____/\\\\\\\\\____\/\\\//\\\_\/\\\__/\\\\\\\\\____.....
//  ...._\/\\\//////\\\____\////////\\\___\/\\\\//\\\\/\\\_\////////\\\___....
//  ....._\/\\\____\//\\\_____/\\\\\\\\\\__\/\\\_\//\\\/\\\___/\\\\\\\\\\__...
//  ......_\/\\\_____\//\\\___/\\\/////\\\__\/\\\__\//\\\\\\__/\\\/////\\\__..
//  ......._\/\\\______\//\\\_\//\\\\\\\\/\\_\/\\\___\//\\\\\_\//\\\\\\\\/\\_.
//  ........_\///________\///___\////////\//__\///_____\/////___\////////\//__
 
//    phy_stator_bi        =1;
//    phy_phaseain         =2;
//    phy_phaseaout        =3;
//    phy_phasebin         =4;
//    phy_phasebout        =5;
//    phy_phasecin         =6;
//    phy_phasecout        =7;
//    phy_rotor_bi         =100;
//    phy_stator_air       =101;
//    phy_stator_mbair     =102;
//    phy_rotor_mbair      =103;
//    phy_rotor_air        =104;
//    phy_rmagnets         =500;
//    phy_rotor_magbase    =500;//+mag count
//    phy_rotor            =700;
//    phy_stator           =701;
//    phy_motor_boundary   =1001;
//    phy_stator_mb        =1002;//+MB count if symmetric
//    phy_rotor_mb         =1006; // + MB count if symmetric
//    phy_goodlooking      =2005;
//    phy_stsymmaster      =3000;
//    phy_stsymslave       =3001;
//    phy_rtsymmaster      =3100;
//    phy_rtsymslave       =3101;
 
//start_time=cpu;
Solver.AutoShowLastStep = 1;
Mesh.Algorithm = 2;
General.NumThreads = 1;
Geometry.CopyMeshingMethod = 1;
General.Verbosity=10;
General.Axes = 0;
General.SmallAxes = 0;
General.LineWidth = 1;
Geometry.PointSize=2;
Geometry.LineWidth=0.5;
Mesh.SurfaceEdges=0;
General.Color.Background = {255,255,255};
General.Color.BackgroundGradient = {255,255,255};
Geometry.Color.Volumes = {255,0,0};
General.DisplayBorderFactor=0;
PostProcessing.HorizontalScales=0;
DefineConstant[ AddTextOverlay = {1, Choices{0,1}, Name "Show winding information?" , Visible 0} ];
    DefineConstant[ colorstrtmpa={"phaseA", readonly 1,Name "phasecolors/1", Highlight "Firebrick2", Visible 1 }];
    DefineConstant[ colorstrtmpb={"phaseB", readonly 1,Name "phasecolors/2", Highlight "LimeGreen", Visible 1 }];
    DefineConstant[ colorstrtmpc={"phaseC", readonly 1,Name "phasecolors/3", Highlight "RoyalBlue3", Visible 1 }];
Include '20191121193103.geo';
boundary_lines[]=Boundary{Physical Surface{1,100,2,3,4,5,6,7};};
Physical Line(2005)={boundary_lines[]};
Hide { Point{ Point '*' }; }
Hide { Line{ Line '*' }; }
    Hide { Surface{ Physical Surface {102} }; }
    Hide { Surface{ Physical Surface {101} }; }
    Hide { Surface{ Physical Surface {103} }; }
    Hide { Surface{ Physical Surface {104} }; }
Show { Line{Physical Line {2005}}; }
//draw;
View.ColormapNumber=23;
//modelbuilt_time=cpu;
//printf('took %f sec to generate geometry.',modelbuilt_time-start_time);
//mesh 2;
//Mesh.MshFileVersion = 2.2;
//save 'motor2d_20191121193103.msh';
//meshed_time=cpu;
//printf('took %f sec to  save the mesh.',meshed_time-modelbuilt_time);
If(AddTextOverlay==1 && PostProcessing.NbViews==0)
    attr     = TextAttributes("Font", "Helvetica", "FontSize", "10", "Align", "CenterCenter");
    View "show winding scheme"{
        T3(0.08201680869952228400,0.00741669121889507180,0.00100000000000000000,attr){"a"};
        T3(0.08151644170987014400,0.01169760440653620400,0.00100000000000000000,attr){"b"};
        T3(0.07809562830292353400,0.02613115110097674300,0.00100000000000000000,attr){"B"};
        T3(0.07662150224789438000,0.03018127915059905900,0.00100000000000000000,attr){"b"};
        T3(0.06996429237021423200,0.04343687386340840100,0.00100000000000000000,attr){"B"};
        T3(0.06759587776699801900,0.04703787332352019800,0.00100000000000000000,attr){"C"};
        T3(0.05806116332624460000,0.05840090351264797000,0.00100000000000000000,attr){"c"};
        T3(0.05492614201914195600,0.06135864357027066100,0.00100000000000000000,attr){"a"};
        T3(0.04302794193878514000,0.07021652533701025500,0.00100000000000000000,attr){"A"};
        T3(0.03929532373793200700,0.07237155346005491600,0.00100000000000000000,attr){"a"};
        T3(0.02567507306403812200,0.07824675610558416700,0.00100000000000000000,attr){"A"};
        T3(0.02154608438279472700,0.07948289417012920100,0.00100000000000000000,attr){"B"};
        T3(0.00693805435466385380,0.08205868399908811100,0.00100000000000000000,attr){"b"};
        T3(0.00263529004158488890,0.08230929148211149600,0.00100000000000000000,attr){"c"};
        T3(-0.01217299666081877700,0.08144680699810252800,0.00100000000000000000,attr){"C"};
        T3(-0.01641757346788619600,0.08069837358532716600,0.00100000000000000000,attr){"c"};
        T3(-0.03062779827545392500,0.07644411155012904900,0.00100000000000000000,attr){"C"};
        T3(-0.03458536134217304900,0.07473698548056238700,0.00100000000000000000,attr){"A"};
        T3(0,0,0.00000000000000000000,attr){"2D_iripm_6p27s_200mmOD_40mmLEN_100Amax"};
    };
    View[0].Visible=0;
EndIf
    //the colors are rgb for phases abc. darker Color shade indicates that positive current comes out of the surface
    Color SlateGrey     {Surface{Physical Surface(1)};}
    Color Khaki {Surface{Physical Surface(101)};}
    Color Yellow {Surface{Physical Surface(102)};}
    Color {230,46,46}             {Surface{Physical Surface(3)};}
    Color {153,31,31} {Surface{Physical Surface(2)};}
    Color {46,230,46}             {Surface{Physical Surface(5)};}
    Color {31,153,31} {Surface{Physical Surface(4)};}
    Color {46,46,230}             {Surface{Physical Surface(7)};}
    Color {31,31,153} {Surface{Physical Surface(6)};}
    Color SlateGrey {Surface{Physical Surface(100)};}
        For k In {1:6}
            If (Fmod(k,2)==1)//odd
                Color Brown {Surface{Physical Surface(500+k)};}
            Else
                Color DarkSlateGrey {Surface{Physical Surface(500+k)};}
            EndIf
        EndFor
    Color Khaki {Surface{Physical Surface(104)};}
    Color Yellow {Surface{Physical Surface(103)};}
Printf('building the 2D model in gmsh is complete. please proceed with further steps.');
