Mesh.Algorithm=6;
Mesh.CharacteristicLengthFromCurvature=1;
Mesh.MinimumCirclePoints=45;

lc = 0.05; // la taille prescrite de l’élément de maille à ce point
a=0.01;
Point(newp) = {1.0000 ,  0.0000 ,  0.00 , a*lc};			
Point(newp) = {0.9998 ,  0.000025 ,  0.00 , a*lc};			
Point(newp) = {0.9990 ,  0.000125 ,  0.00 , a*lc};			
Point(newp) = {0.9978 ,  0.00032 ,  0.00 , a*lc};			
Point(newp) = {0.9961 ,  0.0006 ,  0.00 , a*lc};			
Point(newp) = {0.9938 ,  0.0009 ,  0.00 , a*lc};			
Point(newp) = {0.9911 ,  0.00125 ,  0.00 , a*lc};			
Point(newp) = {0.9880 ,  0.0017 ,  0.00 , a*lc};			
Point(newp) = {0.9843 ,  0.0022 ,  0.00 , a*lc};			
Point(newp) = {0.9801 ,  0.0028 ,  0.00 , a*lc};			
Point(newp) = {0.9755 ,  0.0034 ,  0.00 , a*lc};			
Point(newp) = {0.9704 ,  0.0041 ,  0.00 , a*lc};			
Point(newp) = {0.9649 ,  0.0049 ,  0.00 , a*lc};			
Point(newp) = {0.9589 ,  0.0057 ,  0.00 , a*lc};			
Point(newp) = {0.9524 ,  0.0065 ,  0.00 , a*lc};			
Point(newp) = {0.9455 ,  0.0075 ,  0.00 , a*lc};			
Point(newp) = {0.9382 ,  0.0084 ,  0.00 , a*lc};			
Point(newp) = {0.9304 ,  0.0095 ,  0.00 , a*lc};			
Point(newp) = {0.9222 ,  0.0105 ,  0.00 , a*lc};			
Point(newp) = {0.9135 ,  0.0116 ,  0.00 , a*lc};			
Point(newp) = {0.9045 ,  0.0128 ,  0.00 , a*lc};			
Point(newp) = {0.8951 ,  0.0140 ,  0.00 , a*lc};			
Point(newp) = {0.8853 ,  0.0152 ,  0.00 , a*lc};			
Point(newp) = {0.8751 ,  0.0164 ,  0.00 , a*lc};			
Point(newp) = {0.8645 ,  0.0177 ,  0.00 , a*lc};			
Point(newp) = {0.8536 ,  0.0190 ,  0.00 , a*lc};			
Point(newp) = {0.8423 ,  0.0204 ,  0.00 , a*lc};			
Point(newp) = {0.8307 ,  0.0217 ,  0.00 , a*lc};			
Point(newp) = {0.8187 ,  0.0231 ,  0.00 , a*lc};			
Point(newp) = {0.8065 ,  0.0245 ,  0.00 , a*lc};			
Point(newp) = {0.7939 ,  0.0259 ,  0.00 , a*lc};			
Point(newp) = {0.7810 ,  0.0273 ,  0.00 , a*lc};			
Point(newp) = {0.7679 ,  0.0287 ,  0.00 , a*lc};			
Point(newp) = {0.7545 ,  0.0302 ,  0.00 , a*lc};			
Point(newp) = {0.7409 ,  0.0316 ,  0.00 , a*lc};			
Point(newp) = {0.7270 ,  0.0330 ,  0.00 , a*lc};			
Point(newp) = {0.7129 ,  0.0345 ,  0.00 , a*lc};			
Point(newp) = {0.6986 ,  0.0359 ,  0.00 , a*lc};			
Point(newp) = {0.6841 ,  0.0373 ,  0.00 , a*lc};			
Point(newp) = {0.6694 ,  0.0387 ,  0.00 , a*lc};			
Point(newp) = {0.6545 ,  0.0401 ,  0.00 , a*lc};			
Point(newp) = {0.6395 ,  0.0415 ,  0.00 , a*lc};			
Point(newp) = {0.6243 ,  0.0428 ,  0.00 , a*lc};			
Point(newp) = {0.6091 ,  0.0441 ,  0.00 , a*lc};			
Point(newp) = {0.5937 ,  0.0454 ,  0.00 , a*lc};			
Point(newp) = {0.5782 ,  0.0467 ,  0.00 , a*lc};			
Point(newp) = {0.5627 ,  0.0479 ,  0.00 , a*lc};			
Point(newp) = {0.5471 ,  0.0491 ,  0.00 , a*lc};			
Point(newp) = {0.5314 ,  0.0502 ,  0.00 , a*lc};			
Point(newp) = {0.5157 ,  0.0513 ,  0.00 , a*lc};			
Point(newp) = {0.5000 ,  0.0523 ,  0.00 , a*lc};			
Point(newp) = {0.4843 ,  0.0533 ,  0.00 , a*lc};			
Point(newp) = {0.4686 ,  0.0542 ,  0.00 , a*lc};			
Point(newp) = {0.4529 ,  0.0551 ,  0.00 , a*lc};			
Point(newp) = {0.4373 ,  0.0559 ,  0.00 , a*lc};			
Point(newp) = {0.4218 ,  0.0566 ,  0.00 , a*lc};			
Point(newp) = {0.4063 ,  0.0573 ,  0.00 , a*lc};			
Point(newp) = {0.3909 ,  0.0579 ,  0.00 , a*lc};			
Point(newp) = {0.3757 ,  0.0584 ,  0.00 , a*lc};			
Point(newp) = {0.3605 ,  0.0588 ,  0.00 , a*lc};			
Point(newp) = {0.3455 ,  0.0591 ,  0.00 , a*lc};			
Point(newp) = {0.3306 ,  0.0594 ,  0.00 , a*lc};			
Point(newp) = {0.3159 ,  0.0596 ,  0.00 , a*lc};			
Point(newp) = {0.3014 ,  0.0596 ,  0.00 , a*lc};			
Point(newp) = {0.2871 ,  0.0596 ,  0.00 , a*lc};			
Point(newp) = {0.2730 ,  0.0595 ,  0.00 , a*lc};			
Point(newp) = {0.2591 ,  0.0593 ,  0.00 , a*lc};			
Point(newp) = {0.2455 ,  0.0590 ,  0.00 , a*lc};			
Point(newp) = {0.2321 ,  0.0586 ,  0.00 , a*lc};			
Point(newp) = {0.2190 ,  0.0581 ,  0.00 , a*lc};			
Point(newp) = {0.2061 ,  0.0575 ,  0.00 , a*lc};			
Point(newp) = {0.1935 ,  0.0567 ,  0.00 , a*lc};			
Point(newp) = {0.1813 ,  0.0559 ,  0.00 , a*lc};			
Point(newp) = {0.1693 ,  0.0550 ,  0.00 , a*lc};			
Point(newp) = {0.1577 ,  0.0540 ,  0.00 , a*lc};			
Point(newp) = {0.1464 ,  0.0529 ,  0.00 , a*lc};			
Point(newp) = {0.1355 ,  0.0517 ,  0.00 , a*lc};			
Point(newp) = {0.1249 ,  0.0504 ,  0.00 , a*lc};			
Point(newp) = {0.1147 ,  0.0490 ,  0.00 , a*lc};			
Point(newp) = {0.1049 ,  0.0475 ,  0.00 , a*lc};			
Point(newp) = {0.0955 ,  0.0459 ,  0.00 , a*lc};			
Point(newp) = {0.0865 ,  0.0443 ,  0.00 , a*lc};			
Point(newp) = {0.0778 ,  0.0425 ,  0.00 , a*lc};			
Point(newp) = {0.0696 ,  0.0407 ,  0.00 , a*lc};			
Point(newp) = {0.0618 ,  0.0388 ,  0.00 , a*lc};			
Point(newp) = {0.0545 ,  0.0368 ,  0.00 , a*lc};			
Point(newp) = {0.0476 ,  0.0347 ,  0.00 , a*lc};			
Point(newp) = {0.0411 ,  0.0326 ,  0.00 , a*lc};			
Point(newp) = {0.0351 ,  0.0304 ,  0.00 , a*lc};			
Point(newp) = {0.0296 ,  0.0282 ,  0.00 , a*lc};			
Point(newp) = {0.0245 ,  0.0259 ,  0.00 , a*lc};			
Point(newp) = {0.0199 ,  0.0235 ,  0.00 , a*lc};			
Point(newp) = {0.0157 ,  0.0211 ,  0.00 , a*lc};			
Point(newp) = {0.0120 ,  0.0186 ,  0.00 , a*lc};			
Point(newp) = {0.0089 ,  0.0161 ,  0.00 , a*lc};			
Point(newp) = {0.0062 ,  0.0135 ,  0.00 , a*lc};			
Point(newp) = {0.0039 ,  0.0109 ,  0.00 , a*lc};			
Point(newp) = {0.0022 ,  0.0082 ,  0.00 , a*lc};			
Point(newp) = {0.0010 ,  0.0055 ,  0.00 , a*lc};			
Point(newp) = {0.0002 ,  0.0028 ,  0.00 , a*lc};			
Point(newp) = {0.0000 ,  0.0000 ,  0.00 , a*lc};			
Point(newp) = {0.0002 , - 0.0028 ,  0.00 , a*lc};			
Point(newp) = {0.0010 , - 0.0055 ,  0.00 , a*lc};			
Point(newp) = {0.0022 , - 0.0082 ,  0.00 , a*lc};			
Point(newp) = {0.0039 , - 0.0109 ,  0.00 , a*lc};			
Point(newp) = {0.0062 , - 0.0135 ,  0.00 , a*lc};			
Point(newp) = {0.0089 , - 0.0161 ,  0.00 , a*lc};			
Point(newp) = {0.0120 , - 0.0186 ,  0.00 , a*lc};			
Point(newp) = {0.0157 , - 0.0211 ,  0.00 , a*lc};			
Point(newp) = {0.0199 , - 0.0235 ,  0.00 , a*lc};			
Point(newp) = {0.0245 , - 0.0259 ,  0.00 , a*lc};			
Point(newp) = {0.0296 , - 0.0282 ,  0.00 , a*lc};			
Point(newp) = {0.0351 , - 0.0304 ,  0.00 , a*lc};			
Point(newp) = {0.0411 , - 0.0326 ,  0.00 , a*lc};			
Point(newp) = {0.0476 , - 0.0347 ,  0.00 , a*lc};			
Point(newp) = {0.0545 , - 0.0368 ,  0.00 , a*lc};			
Point(newp) = {0.0618 , - 0.0388 ,  0.00 , a*lc};			
Point(newp) = {0.0696 , - 0.0407 ,  0.00 , a*lc};			
Point(newp) = {0.0778 , - 0.0425 ,  0.00 , a*lc};			
Point(newp) = {0.0865 , - 0.0443 ,  0.00 , a*lc};			
Point(newp) = {0.0955 , - 0.0459 ,  0.00 , a*lc};			
Point(newp) = {0.1049 , - 0.0475 ,  0.00 , a*lc};			
Point(newp) = {0.1147 , - 0.0490 ,  0.00 , a*lc};			
Point(newp) = {0.1249 , - 0.0504 ,  0.00 , a*lc};			
Point(newp) = {0.1355 , - 0.0517 ,  0.00 , a*lc};			
Point(newp) = {0.1464 , - 0.0529 ,  0.00 , a*lc};			
Point(newp) = {0.1577 , - 0.0540 ,  0.00 , a*lc};			
Point(newp) = {0.1693 , - 0.0550 ,  0.00 , a*lc};			
Point(newp) = {0.1813 , - 0.0559 ,  0.00 , a*lc};			
Point(newp) = {0.1935 , - 0.0567 ,  0.00 , a*lc};			
Point(newp) = {0.2061 , - 0.0575 ,  0.00 , a*lc};			
Point(newp) = {0.2190 , - 0.0581 ,  0.00 , a*lc};			
Point(newp) = {0.2321 , - 0.0586 ,  0.00 , a*lc};			
Point(newp) = {0.2455 , - 0.0590 ,  0.00 , a*lc};			
Point(newp) = {0.2591 , - 0.0593 ,  0.00 , a*lc};			
Point(newp) = {0.2730 , - 0.0595 ,  0.00 , a*lc};			
Point(newp) = {0.2871 , - 0.0596 ,  0.00 , a*lc};			
Point(newp) = {0.3014 , - 0.0596 ,  0.00 , a*lc};			
Point(newp) = {0.3159 , - 0.0596 ,  0.00 , a*lc};			
Point(newp) = {0.3306 , - 0.0594 ,  0.00 , a*lc};			
Point(newp) = {0.3455 , - 0.0591 ,  0.00 , a*lc};			
Point(newp) = {0.3605 , - 0.0588 ,  0.00 , a*lc};			
Point(newp) = {0.3757 , - 0.0584 ,  0.00 , a*lc};			
Point(newp) = {0.3909 , - 0.0579 ,  0.00 , a*lc};			
Point(newp) = {0.4063 , - 0.0573 ,  0.00 , a*lc};			
Point(newp) = {0.4218 , - 0.0566 ,  0.00 , a*lc};			
Point(newp) = {0.4373 , - 0.0559 ,  0.00 , a*lc};			
Point(newp) = {0.4529 , - 0.0551 ,  0.00 , a*lc};			
Point(newp) = {0.4686 , - 0.0542 ,  0.00 , a*lc};			
Point(newp) = {0.4843 , - 0.0533 ,  0.00 , a*lc};			
Point(newp) = {0.5000 , - 0.0523 ,  0.00 , a*lc};			
Point(newp) = {0.5157 , - 0.0513 ,  0.00 , a*lc};			
Point(newp) = {0.5314 , - 0.0502 ,  0.00 , a*lc};			
Point(newp) = {0.5471 , - 0.0491 ,  0.00 , a*lc};			
Point(newp) = {0.5627 , - 0.0479 ,  0.00 , a*lc};			
Point(newp) = {0.5782 , - 0.0467 ,  0.00 , a*lc};			
Point(newp) = {0.5937 , - 0.0454 ,  0.00 , a*lc};			
Point(newp) = {0.6091 , - 0.0441 ,  0.00 , a*lc};			
Point(newp) = {0.6243 , - 0.0428 ,  0.00 , a*lc};			
Point(newp) = {0.6395 , - 0.0415 ,  0.00 , a*lc};			
Point(newp) = {0.6545 , - 0.0401 ,  0.00 , a*lc};			
Point(newp) = {0.6694 , - 0.0387 ,  0.00 , a*lc};			
Point(newp) = {0.6841 , - 0.0373 ,  0.00 , a*lc};			
Point(newp) = {0.6986 , - 0.0359 ,  0.00 , a*lc};			
Point(newp) = {0.7129 , - 0.0345 ,  0.00 , a*lc};			
Point(newp) = {0.7270 , - 0.0330 ,  0.00 , a*lc};			
Point(newp) = {0.7409 , - 0.0316 ,  0.00 , a*lc};			
Point(newp) = {0.7545 , - 0.0302 ,  0.00 , a*lc};			
Point(newp) = {0.7679 , - 0.0287 ,  0.00 , a*lc};			
Point(newp) = {0.7810 , - 0.0273 ,  0.00 , a*lc};			
Point(newp) = {0.7939 , - 0.0259 ,  0.00 , a*lc};			
Point(newp) = {0.8065 , - 0.0245 ,  0.00 , a*lc};			
Point(newp) = {0.8187 , - 0.0231 ,  0.00 , a*lc};			
Point(newp) = {0.8307 , - 0.0217 ,  0.00 , a*lc};			
Point(newp) = {0.8423 , - 0.0204 ,  0.00 , a*lc};			
Point(newp) = {0.8536 , - 0.0190 ,  0.00 , a*lc};			
Point(newp) = {0.8645 , - 0.0177 ,  0.00 , a*lc};			
Point(newp) = {0.8751 , - 0.0164 ,  0.00 , a*lc};			
Point(newp) = {0.8853 , - 0.0152 ,  0.00 , a*lc};			
Point(newp) = {0.8951 , - 0.0140 ,  0.00 , a*lc};			
Point(newp) = {0.9045 , - 0.0128 ,  0.00 , a*lc};			
Point(newp) = {0.9135 , - 0.0116 ,  0.00 , a*lc};			
Point(newp) = {0.9222 , - 0.0105 ,  0.00 , a*lc};			
Point(newp) = {0.9304 , - 0.0095 ,  0.00 , a*lc};			
Point(newp) = {0.9382 , - 0.0084 ,  0.00 , a*lc};			
Point(newp) = {0.9455 , - 0.0075 ,  0.00 , a*lc};			
Point(newp) = {0.9524 , - 0.0065 ,  0.00 , a*lc};			
Point(newp) = {0.9589 , - 0.0057 ,  0.00 , a*lc};			
Point(newp) = {0.9649 , - 0.0049 ,  0.00 , a*lc};			
Point(newp) = {0.9704 , - 0.0041 ,  0.00 , a*lc};			
Point(newp) = {0.9755 , - 0.0034 ,  0.00 , a*lc};			
Point(newp) = {0.9801 , - 0.0028 ,  0.00 , a*lc};			
Point(newp) = {0.9843 , - 0.0022 ,  0.00 , a*lc};			
Point(newp) = {0.9880 , - 0.0017 ,  0.00 , a*lc};			
Point(newp) = {0.9911 , - 0.00125 ,  0.00 , a*lc};			
Point(newp) = {0.9938 , - 0.0009 ,  0.00 , a*lc};			
Point(newp) = {0.9961 , - 0.0006 ,  0.00 , a*lc};			
Point(newp) = {0.9978 , - 0.00032 ,  0.00 , a*lc};			
Point(newp) = {0.9990 , - 0.000125 ,  0.00 , a*lc};				
Point(newp) = {0.9998 , -0.000025 ,  0.00 , a*lc};

//===================== Définition des courbes======================			
//+
Spline(1) = {1 ... 65};
//+
Spline(2) = {65 ... 138};
//+
Spline(3) = {138 ... 200,1};

//=========================================== Définition du domaine	
// Let's create a simple domain, rectangular and semi-circular
diff = 15;
Point(newp) = {0.0, diff, 0, lc*10}; // UPPER
Point(newp) = {-diff, 0, 0, lc*10}; // LE     
Point(newp) = {0, -diff, 0, lc*10}; // LOWER
Point(newp) = {(diff+5), -diff, 0, lc*10}; // LOWER_FAR
Point(newp) = {(diff+5), diff, 0, lc*10}; // UPPER_FAR//+

//================== Définition des courbes	=========================
Circle(4) = {201, 101, 202};
//+
Circle(5) = {202, 101, 203};
//+
Line(6) = {203, 204};
//+
Line(7) = {204, 205};
//+
Line(8) = {205, 201};

//=========================================== Définition de la surface plane
//+
Curve Loop(1) = {8, 4, 5, 6, 7};
//+
Curve Loop(2) = {1, 2, 3};
//+
Plane Surface(1) = {1, 2};


//=========================================== Définition des entités physiques
//+
Physical Curve("Inlet") = {4, 5};
//+
Physical Curve("Outlet") = {7};
//+
Physical Curve("Top") = {8};
//+
Physical Curve("Down") = {6};
//+
Physical Curve("Profil") = {1, 2, 3};
//+
Physical Surface("Fluid") = {1};

//===========================================
Field[1] = BoundaryLayer;
//+
Field[1].EdgesList = {1, 2, 3};          //Indice de courbes dans le modèle géométrique pour lesquelles une couche limite est nécessaire
//+
Field[1].FanNodesList = {1};                      // Indice de points dans le modèle géométrique pour lequel un fan est créé // pour creer un bon maillage au bord de fuite LE
//+
Field[1].hfar = 10*lc;                               // Taille des éléments loin de la paroi
//+
Field[1].hwall_n = 0.0001;                           // Taille de maille normalement à la paroi
//+
Field[1].ratio = 1.2;                                // Rapport de taille entre deux couches successives
//+
Field[1].thickness = 0.006;                           // épaisseur de la CL
//+
Field[1].Quads = 1;                                 //génère des éléments recombinés dans la CL
//+
BoundaryLayer Field = 1;


//=========================================== rafinnement de la CL
Field[2] = Distance;
Field[2].EdgesList = {1, 2, 3};
Field[2].NNodesByEdge = 4000;
//===========================================
Field[3] = Threshold;
Field[3].DistMax = 1;             //Distance compté à partire de l’entité après laquelle la taille de l’élément sera Lcmax
Field[3].DistMin = 0.01;             //Distance de l'entité au dessus duquel la taille de l’élément sera Lcmin
Field[3].IField = 2;                //Indice du domaine à évaluer
Field[3].LcMax = 10*lc;             //Taille de l'élément au dela de DistMax (dans la region hors de DistMax)
Field[3].LcMin = lc/30;           // Taille de l'élément en deca de DistMin
Field[3].Sigmoid = 1;               //Vrai (1) pour interpoler entre Lcmin et Lcmax en utilisant un sigmoïde, faux (0) pour interpoler linéairement

//===========================================Definition du domaine dans le scillage

Field[4] = Box;
Field[4].VIn = lc;           //valeur à l'intérieur du box
Field[4].VOut = 10*lc;       //valeur à l'extérieur du box
Field[4].XMax = (diff+5);     // Coordonnées max de X
Field[4].XMin = 1;         // Coordonnées min de X
Field[4].YMax = (diff/20);
Field[4].YMin = (-diff/20);
Field[4].ZMax = 1;
Field[4].ZMin = -1;
Field[4].Thickness = 1.1;

Field[5] = Box;
Field[5].VIn = 2*lc;
Field[5].VOut = 100*lc;
Field[5].XMax = (diff+5);
Field[5].XMin = 1; 
Field[5].YMax = (diff/10);
Field[5].YMin = (-diff/10);
Field[5].ZMax = 1;
Field[5].ZMin = -1;
Field[5].Thickness = 1.1;

//=========================================== Direction de raffinement dans le scillage
Point(228) = {(diff+5), -0.00, -0.00, 1.0};    //on définit un point loin dans le scillage
Line(1000) = {1, 228};                     //Liaison avec le bord de fuite

//=========================
Field[6] = Distance;
Field[6].EdgesList = {1000};
Field[6].NNodesByEdge = 2000;
//=========================
Field[7] = Threshold;
Field[7].DistMax = 0.5;             //Distance compté à partire de l’entité après laquelle la taille de l’élément sera Lcmax
Field[7].DistMin = 0.1;             //Distance de l'entité au dessus duquel la taille de l’élément sera Lcmin
Field[7].IField = 6;                //Indice du domaine à évaluer
Field[7].LcMax = 10*lc;             //Taille de l'élément au dela de DistMax (dans la region hors de DistMax)
Field[7].LcMin = lc/2;           // Taille de l'élément en deca de DistMin
Field[7].Sigmoid = 1;               //Vrai (1) pour interpoler entre Lcmin et Lcmax en utilisant un sigmoïde, faux (0) pour interpoler linéairement
//===========================================
Field[8] = Min;
Field[8].FieldsList = {3, 4, 5, 7};
Background Field = 8;