// Gmsh project created on Tue Oct 24 16:39:00 2017


SetFactory("OpenCASCADE");
Merge "AileM6_with_sharp_TE.stp";
SetFactory("OpenCASCADE");
Sphere(2) = {400, 0, 0, 25000, -Pi/2, Pi/2, Pi};



//+
BooleanDifference{ Volume{2}; Delete; }{ Volume{1}; Delete; }
Physical Surface("wing") = {15, 14, 17, 16, 10, 9, 7, 4, 5, 8};
Physical Surface("symmetry") = {12, 13};
Physical Surface("farfield") = {11};
Physical Volume(4) = {2};

//Mesh.Algorithm = 7;


surf_len = 0.04;
lete_factor = 0.25;

Mesh.CharacteristicLengthFactor = 20;
Mesh.CharacteristicLengthMax = 5000;
Mesh.CharacteristicLengthMin = 0;
//Mesh.CharacteristicLengthExtendFromBoundary = 0;
//Mesh.SaveParametric = 1;
//+
//Characteristic Length {20, 16, 15, 17} = 10;
//+
//Physical Line(5) = {25, 29, 23, 26, 30, 33, 28, 27, 35, 37, 36, 31, 32, 34, 17, 21, 12, 8, 19, 13, 14, 3, 15, 20, 16, 2, 7};
//+
//Characteristic Length {10, 3, 2, 7, 11, 8} = 10;
//+
//Characteristic Length {13, 14} = 200;
//+


Field[1] = Attractor;// wing
Field[1].EdgesList = {35, 36, 37,27,28,33,30,3,13,8,19,14,17,12,21,2,16,15,20,7};
Field[1].NNodesByEdge = 200;
Field[2] = Threshold;
Field[2].IField = 1;
Field[2].DistMax = 500;
Field[2].DistMin = 100;
Field[2].LcMax = 200;
Field[2].LcMin = 3;


//%%%%%%%%%%%%% farfield%%%%%%%%%%%%%%%%%%%%%%%%%%
Field[3] = Attractor;
//+
Field[3].EdgesList = {23, 25};
//+
Field[3].NNodesByEdge = 200;
//+
Field[4] = Threshold;
//+
Field[4].DistMax = 50;
//+
Field[4].DistMin = 50;
//+
Field[4].IField = 3;
//+
Field[4].LcMax = 200;
//+
Field[4].LcMin = 1000;

Field[5] = Box;
Field[5].VIn = 10;
Field[5].VOut = 200;
Field[5].XMin = -100;
Field[5].XMax = 1000;
Field[5].YMin = 0;
Field[5].YMax = 1500;
Field[5].ZMin = -1000;
Field[5].ZMax = 1000;

Field[7] = Box;
Field[7].VIn = 5;
Field[7].VOut = 200;
Field[7].XMin = -3000;
Field[7].XMax = 3000;
Field[7].YMin = 0;
Field[7].YMax = 2500;
Field[7].ZMin = -3000;
Field[7].ZMax = 3000;


Field[10] = Min;
Field[10].FieldsList = {2,4,5,7};
Background Field = 10;

Field[6] = BoundaryLayer;
Field[6].EdgesList = {35, 36, 37,27,28,33,30,3,13,8,19,14,17,12,21,2,16,15,20,7};
Field[6].hfar = 10;
Field[6].ratio = 1.1;
Field[6].thickness = 3;
Field[6].hwall_n = 0.01;
Field[6].hwall_n_nodes = 0.01;
Field[6].NodesList = {18, 19, 20, 17, 15, 16,10,8,4,12,11,7,2,3};
//BoundaryLayer Field = 6;
Background Field = 6;


//+
Field[6].FanNodesList = {18, 19, 20, 17, 15, 16,10,8,4,12,11,7,2,3};
//+
Field[6].IntersectMetrics = 1;
//+
Field[6].Quads = 5;
//+
Field[6].hwall_n = 1;
//+
Field[6].hwall_n_nodes = {1};
//+
Field[6].thickness = 1;
