// load shape global properties computed in shape_from_contour.py
Include "scat2D_data.geo";
// load shape Spline surface computed in shape_from_contour.py
Include "shape.geo";
// scale and rotate shape
Dilate { { 0,0,0 }, shape_size } { Surface{1}; }
Rotate { { 0,0,1 }, { 0,0,0 }, shape_rotation*deg2rad } { Surface{1}; }

// compute refractive indices
n_shape = Sqrt(epsr_shape_re*mur_shape_re);
n_bg    = Sqrt(epsr_bg_re);

paramaille_pml = paramaille/1.2;

lc_shape = lambda0/(paramaille*n_shape);
lc_PML  = lambda0/(paramaille_pml);
lc_bg   = lambda0/(paramaille*n_bg);

lc_src  = r_src/2;
// cartesian PMLS
Rectangle(2)  = {-dom_x/2-PML_size, -dom_y/2-PML_size , 0, PML_size , PML_size};
Rectangle(3)  = {-dom_x/2-PML_size, -dom_y/2 , 0, PML_size , dom_y};
Rectangle(4)  = {-dom_x/2-PML_size,  dom_y/2 , 0, PML_size , PML_size};

Rectangle(5)  = {dom_x/2, -dom_y/2-PML_size , 0, PML_size , PML_size};
Rectangle(6)  = {dom_x/2, -dom_y/2 , 0, PML_size , dom_y};
Rectangle(7)  = {dom_x/2,  dom_y/2 , 0, PML_size , PML_size};

Rectangle(8)  = {-dom_x/2, -dom_y/2-PML_size , 0, dom_x , PML_size};
Rectangle(9)  = {-dom_x/2, dom_y/2 , 0, dom_x , PML_size};

//domain
Rectangle(10)  = {-dom_x/2, -dom_y/2 , 0, dom_x , dom_y};

// scatters
Disk (11) = {x_src, y_src , 0, r_src}; 
Coherence;

// set physical tags and names
Physical Surface("PMLXY" , 1001) = {2,5,7,4}; // PMLxy
Physical Surface("PMLX"  , 1002) = {3,6};     // PMLx
Physical Surface("PMLY"  , 1003) = {8,9};     // PMLy
Physical Surface("PTSRC" , 1004) = {11};      // pt src
Physical Surface("SHAPE" , 1005) = {1};       // shape
Physical Surface("BG"    , 1006) = {12};      // BackGnd

// set characteristic lengths per domain
// (coarse mesh size to small mesh size)
Characteristic Length{PointsOf{Physical Surface{1001};}} = lc_PML ;
Characteristic Length{PointsOf{Physical Surface{1002};}} = lc_PML ;
Characteristic Length{PointsOf{Physical Surface{1003};}} = lc_PML ;
Characteristic Length{PointsOf{Physical Surface{1006};}} = lc_bg ;
Characteristic Length{PointsOf{Physical Surface{1005};}} = lc_shape ;
Characteristic Length{PointsOf{Physical Surface{1004};}} = lc_src ;

// nice visu of Splines : increase NumSubEdges
Geometry.NumSubEdges = shape_npts;
Geometry.Points = 0;
Geometry.Color.Curves = {0,0,0};
