// Gmsh project created on Wed Mar 20 17:41:38 2019
SetFactory("OpenCASCADE");

// Geometry.ScalingFactor = 0.001;
Merge "wing_fuselage.step";


//lc = 50;
//Mesh.CharacteristicLengthMin = lc/100;
//Mesh.CharacteristicLengthMax = lc;

// distance on leading edge and fairing
Field[1] = Distance;
Field[1].EdgesList = {7,20,  29,12,  3,5,10,11,  17,23,24,30};
Field[1].NNodesByEdge = 100;

Field[11] = Threshold;
Field[11].DistMax = 50;
Field[11].DistMin = 15;
Field[11].IField = 1;
Field[11].LcMax = 20;
Field[11].LcMin = 2;


// distance on fuselage
Field[2] = Distance;
Field[2].EdgesList = {1,22};
Field[2].NNodesByEdge = 100;

Field[12] = Threshold;
Field[12].DistMax = 15;
Field[12].DistMin = 5;
Field[12].IField = 2;
Field[12].LcMax = 5;
Field[12].LcMin = 2;

Field[21] = Min;
Field[21].FieldsList = {11,12};

Background Field = 21;

Mesh.CharacteristicLengthExtendFromBoundary = 0;    // large influence!!
Mesh.CharacteristicLengthFromPoints = 1;
Mesh.CharacteristicLengthFromCurvature = 0;

Physical Surface("wingfuselage", 101) = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};




/*

// BOUNDING BOX
lcbox      = 500;
Point(101) = {-5000, -5000, -5000, lcbox};
Point(102) = {-5000, -5000,  5000, lcbox};
Point(103) = {-5000,  5000, -5000, lcbox};
Point(104) = {-5000,  5000,  5000, lcbox};

Line(111) = {101,103};
Line(112) = {103,104};
Line(113) = {104,102};
Line(114) = {102,101};
Line Loop(115) = {111,112,113,114};
Plane Surface(1001) = {115};
aux[] = Extrude {10000,0,0} { Surface{1001};};
volbox = aux[1];
bndbox[] = Boundary{Volume{volbox};};
slbndbox=newsl; Surface Loop(slbndbox) = bndbox[];

// Keep just the boundary
Delete {
  Volume{volbox};
}

*/