Insert_BL=1; //SWITCH TO CONTROL BOUNDARY LAYER INSERTION 0 or 1

// --- IMPORTED SURFACES --- //

// UJointPIDS.nas
Merge "UJointPIDS.nas";
Physical Surface("Top") = {202};
Physical Surface("Base") = {203};
Physical Surface("Sides") = {204};



If (Insert_BL == 0)
  // ... OVERALL TEST BODY
  Surface Loop(10001)={202,203,204};
  Physical Surface("TestBody") = {10001};
EndIf
If (Insert_BL == 1)
  // TRY OUT BL OFFSETS
  BL[]=Extrude { Surface{202,203,204}; Layers{ {1,1}, {0.5,1}}; };
  Physical Surface("Surf BL") = BL[0];  
  Physical Volume("Fluid BL") = BL[1];
  Surface Loop(10001)=BL[0];
EndIf

// --- ENCLOSING BOUNDING VOLUME --- //

xmin = General.MinX;
xmax = General.MaxX;
ymin = General.MinY;
ymax = General.MaxY;
zmin = General.MinZ;
zmax = General.MaxZ;

l = Sqrt((xmax - xmin)^2 + (ymax - ymin)^2 + (zmax - zmin)^2) / 10;
lc = 2;

Point(1) = { xmin - l, ymin - l, zmin - l, lc};
Point(2) = { xmax + 4.*l, ymin - l, zmin - l, lc};
Point(3) = { xmax + 4.*l, ymax + l, zmin - l, lc};
Point(4) = { xmin - l, ymax + l, zmin - l, lc};

Line(1) = {4, 3}; Line(2) = {3, 2}; Line(3) = {2, 1}; Line(4) = {1, 4};

Line Loop(1) = {2, 3, 4, 1};


Plane Surface(2001) = {1}; Physical Surface("Floor") = {2001};

Point(5) = { xmin - l, ymin - l, zmax + l, lc};
Point(6) = { xmax + 4.*l, ymin - l, zmax + l, lc};
Point(7) = { xmax + 4.*l, ymax + l, zmax + l, lc};
Point(8) = { xmin - l, ymax + l, zmax + l, lc};

Line(5) = {5, 6}; Line(6) = {6, 7}; Line(7) = {7, 8}; Line(8) = {8, 5};

Line Loop(2) = {5,6,7,8};
Plane Surface(2002) = {2}; Physical Surface("Ceiling") = {2002};

Line(9) = {5, 1}; Line(10) = {4, 8};

Line Loop(3) = {-8,-10,-4,-9};
Plane Surface(2003) = {3}; Physical Surface("Inlet") = {2003};

Line(11) = {2, 6}; Line(12) = {7, 3};

Line Loop(4) = {-2,-12,-6,-11};
Plane Surface(2004) = {4}; Physical Surface("Outlet") = {2004};

Line Loop(5) = {-3,11,-5,9};
Plane Surface(2005) = {5}; Physical Surface("SideWall_1") = {2005};

Line Loop(6) = {10,-7,12,-1};
Plane Surface(2006) = {6}; Physical Surface("SideWall_2") = {2006};



Surface Loop(10002)={ 2001, 2002, 2003, 2004, 2005, 2006 };
Physical Surface("WindTunnel") = {10002};


// --- FINAL VOLUMES --- //


Volume(100001)={ 10001, 10002 };
Physical Volume("Fluid") = {100001};
