// Gmsh project created on Tue Oct 24 16:39:00 2017
// Chord length of the wing = 800 mm

//————————————————
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};

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};
//——————————————————————

//————————————————————
//Mesh.Algorithm = 1;

fflc = 100;

Mesh.CharacteristicLengthFactor=10; //global mesh 
Mesh.CharacteristicLengthMax = fflc; // max mesh size
Mesh.CharacteristicLengthMin = 0;    // min mesh size
//Mesh.CharacteristicLengthExtendFromBoundary = 80;
//Mesh.SaveParametric = 1;
//Mesh.CharacteristicLengthFromCurvature=0.1;
//+
//Characteristic Length {20, 16, 15, 17} = 0.5;
//+
//+
//Characteristic Length {10, 3, 2, 7, 11, 8} = 0.5;
//+
Characteristic Length {13, 14} = 100;
//+
//+

//grid refinement near the wing————————
//+
Field[1] = Attractor;
//+
Field[1].EdgesList = {30, 33, 35, 3, 8, 13, 34, 36, 37, 17, 21, 12, 19, 14, 2, 7, 20, 16, 15,32,31,36,34,37};

//+
//Field[1].FacesList = {14, 15, 4, 7, 17, 16, 9, 10, 5, 8};
//+
Field[1].NNodesByEdge = 100;
//+
//Field[1].NodesList = {16, 17, 15, 18, 19, 20, 10, 8, 4, 12, 2, 3, 7, 11};


Field[2] = Threshold;
//+
Field[2].DistMax = 200;
//+
Field[2].DistMin = 100;
//+
Field[2].IField = 1;
//+
Field[2].LcMax = 10;
Field[2].LcMin = 1;

// Grid coarse at Fairfield boundary ———————————
//+
Field[3] = Attractor;
//+
Field[3].EdgesList = {23, 25};
//+
Field[3].NNodesByEdge = 100;
Field[3].FacesList = {12, 13, 11};
//+
Field[4] = Threshold;
//+
Field[4].DistMax = 500;
//+
Field[4].DistMin = 100;
//+
Field[4].LcMax = 100;
//+
Field[4].LcMin = 150;
//+
Field[4].IField = 3;
//+

//+
Field[5] = Max;
//+
Delete Field [5];
//+
Field[5] = Distance;
//+
Delete Field [5];
