
// ****************************** File created by AUTOPILOT ******************************
// ****************************** ANDREW TSIANTIS 2017-2019 ******************************
//                                   2D Geometry
// 
//  Flakes: 2000 
//  Geometry data
//  size X=0.5, Y=1
//  Flake size w=0.015811, t=0.000016
//  Rotation th=0 +/- 0
//  af= 1.0119
//  
// ***************************************************************************************
Merge "P.brep";
SetFactory("OpenCASCADE");

Mesh.CharacteristicLengthFromPoints =0;
Mesh.CharacteristicLengthExtendFromBoundary = 0;

size_x = 1;
size_y = 1;
size_z = 1;//
size_fz = 1;
stp = 1;
Mesh.CharacteristicLengthFactor= 0.055;
General.Verbosity =4;
Mesh.Smoothing =0;
Mesh.Optimize =0;
Mesh.RandomFactor=1e-6;
Mesh.RecombineAll =0;
Mesh.Algorithm=5;
Bx=0.5;
By=1;
bStep=0.000001;
//+
Extrude {0, 0, 1} {
  Surface{1}; Layers{1}; Recombine;
}

p[]=Point "*";
Field[1] = Attractor;
//Field[1].EdgesList = {l[]};

Field[1].NodesList = {p[]};
Field[2] = Threshold;
Field[2].IField = 1;
Field[2].LcMin = 0.003;
Field[2].LcMax = 0.02;
Field[2].DistMin = 0.002;
Field[2].DistMax = 0.02;

Background Field = 2;
v[]=Volume "*";
all_s[]=Surface "*";

t[] = Surface In BoundingBox {-bStep, By-bStep, -0.000001, Bx+bStep, By+bStep, 1.000001};
bt[] = Surface In BoundingBox{-bStep, -bStep, -0.000001, Bx+bStep, bStep,1.000001};
l[] = Surface In BoundingBox {-bStep, -bStep, -0.000001, bStep, By+bStep, 1.000001};
r[] = Surface In BoundingBox {Bx-bStep, -bStep, -0.000001, Bx+bStep, By+bStep, 1.000001};
f[] = Surface In BoundingBox {-bStep, -bStep, 0.999999, Bx+bStep, By+bStep, 1.000001};
b[] = Surface In BoundingBox {-bStep, -bStep, -0.000001, Bx+bStep, By+bStep, 0.000001};

i[]=all_s[];
i[]-=t[];
i[]-=bt[];
i[]-=l[];
i[]-=r[];
i[]-=b[];
i[]-=f[];
Physical Surface ("top")=t[];
Physical Surface("bottom") = bt[];
Physical Surface("left_1") = l[];
Physical Surface("right_1") = r[];
Physical Surface("back_1") = b[];
Physical Surface("front_1") = f[];
Physical Surface("internal_1") = i[];
Physical Volume("vol_1")=v[];

SyncModel;
Mesh 3;
Coherence Mesh;
Save 'g.msh';

