DefineConstant[
  ArteryType  = { 1, Name "Parameters/1Geometry/4ArteryType", Label "Artery type"}
  AR = {0.0125, Name "Parameters/1Geometry/Artery_radius", 
	Label "Artery radius", Closed "0"},
  WT = {0.0020, Name "Parameters/1Geometry/Wall_thickness", 
	Label "Wall thickness"},
  VR = {0.0250, Name "Parameters/1Geometry/Ventricle radius", 
	Label "Ventricle radius"},
  VL = {0.0800, Name "Parameters/1Geometry/Ventricle length", 
	Label "Ventricle length"},
  ABL = {0.0300, Name "Parameters/1Geometry/Valve_length", 
	 Label "Artery base length"},
  AL = {0.40, Name "Parameters/1Geometry/Artery_length", 
	Label "Artery length"} 
];

// Mesh size
DefineConstant[ lc = {AR/5, Name "Parameters/1Geometry/Mesh size", Label "Mesh size"} ];

// Defining size and position of atheroma on inner surface of artery
DefineConstant[ 
  olATL = {0.010, Name "Parameters/1Geometry/5Circle_length", 
	   Label "Atheroma Length"}, 
  olATC = {0.1, Name "Parameters/1Geometry/5Circle_center", 
	   Label "Atheroma center"} , 
  olATW = {0.005, Name "Parameters/1Geometry/5Circle_width", 
	   Label "Atheroma Width"} ,
  olSTL =  {0.1, Name "Parameters/1Geometry/5Stenose_length", 
	    Label "Stenose Length"},
  olSTC =  {0.1, Name "Parameters/1Geometry/5Stenose_center", 
	    Label "Stenose Center"},
  olSTW =  {0.005, Name "Parameters/1Geometry/5Stenose_width", 
	    Label "Stenose Width"}
];

Div1=50;
Div2=10;

If(ArteryType == 1)
  STL = 0.0001;
  STC = AL-0.0001;
  STW = 0;
  ATL = 0;
  ATC = 0;
  ATW = 0;
  Div1 = 2;
  Div2 = 2;
EndIf
If(ArteryType == 2)
  STL = olSTL;
  STC = olSTC;
  STW = olSTW;
  ATL = 0;
  ATC = 0;
  ATW = 0;
EndIf
If(ArteryType == 3)
  STL = 0;
  STC = 0;
  STW = 0;
  ATL = olATL;
  ATC = olATC;
  ATW = olATW;
EndIf


Point(1) = {0.0  , 0.0, 0, lc};
Point(2) = {AR   , 0.0, 0, lc};
Point(3) = {AR+WT, 0.0, 0, lc};
Point(4) = {VR   , 0.0, 0, lc};

Point(11) = {0.0  , VL, 0, lc};
Point(12) = {AR   , VL, 0, lc};
Point(13) = {AR+WT, VL, 0, lc};
Point(14) = {VR   , VL, 0, lc};

Point(21) = {0.0  , VL+ABL, 0, lc};
Point(22) = {AR   , VL+ABL, 0, lc};
Point(23) = {AR+WT, VL+ABL, 0, lc};

Point(31) = {0.0  , VL+ABL+AL, 0, lc};
Point(32) = {AR   , VL+ABL+AL, 0, lc};
Point(33) = {AR+WT, VL+ABL+AL, 0, lc};

Point(41) = {0.0   , VL+ABL+ATC-ATL/2+STC-STL/2, 0, lc};
Point(42) = {AR    , VL+ABL+ATC-ATL/2+STC-STL/2, 0, lc};
Point(43) = {AR+WT , VL+ABL+ATC-ATL/2+STC-STL/2, 0, lc};

Point(61) = {AR-STW-ATW, VL+ABL+ATC+STC, 0, lc};
Point(62) = {AR+WT-STW , VL+ABL+ATC+STC, 0, lc};

Point(51) = {0.0   , VL+ABL+ATC+ATL/2+STC+STL/2, 0, lc};
Point(52) = {AR    , VL+ABL+ATC+ATL/2+STC+STL/2, 0, lc};
Point(53) = {AR+WT , VL+ABL+ATC+ATL/2+STC+STL/2, 0, lc};

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

Line(4) = {1, 11};
Line(5) = {2, 12};
Line(6) = {3, 13};
Line(7) = {4, 14};

Line(11) = {11, 12};
Line(12) = {12, 13};
Line(13) = {13, 14};

Line(14) = {11, 21};
Line(15) = {12, 22};
Line(16) = {13, 23};

Line(21) = {21, 22};
Line(22) = {22, 23};

Line(23) = {21, 41};
Line(24) = {22, 42};
Line(25) = {23, 43};

Line(41) = {41, 42};
Line(42) = {42, 43};

Line(43) = {41, 51};
Spline(44) = {52, 61, 42};
Spline(45) = {43, 62, 53};


Line(51) = {51, 52};
Line(52) = {52, 53};

Line(53) = {51, 31};
Line(54) = {52, 32};
Line(55) = {53, 33};

Line(31) = {31, 32};
Line(32) = {32, 33};


Line Loop(101) = {1, 5, -11, -4};
Line Loop(102) = {2, 6, -12, -5};
Line Loop(103) = {3, 7, -13, -6};

Line Loop(111) = {11, 15, -21, -14};

Line Loop(121) = {21, 24, -41, -23};
Line Loop(122) = {22, 25, -42, -24};

Line Loop(141) = {41, -44, -51, -43};
Line Loop(142) = {-44, -42, -45, 52};

Line Loop(151) = {51, 54, -31, -53};
Line Loop(152) = {52, 55, -32, -54};


Plane Surface(201) = {101};
Plane Surface(202) = {102};
Plane Surface(203) = {103};
Plane Surface(211) = {111};
Plane Surface(221) = {121};
Plane Surface(222) = {122};
Plane Surface(241) = {141};
Plane Surface(242) = {142};
Plane Surface(251) = {151};
Plane Surface(252) = {152};


Coherence;

Transfinite Line {1, 11, 21, 41, 51, 31} = 20 Using Progression 0.94 ;
Transfinite Line {2, 12, 22, 42, 52, 32} = 6 ;
Transfinite Line {3, 13} = 6 ;

Transfinite Line {4, 5, 6, 7} = 6 ;
Transfinite Line {14, 15, 16} = 6 ;
Transfinite Line {-23, -24, -25} = 50 Using Progression 0.97 ;
Transfinite Line {-53, -54, -55} = Div1 Using Progression 0.97 ;

Transfinite Line {43, 44, 45} = Div2 ;

Transfinite Surface {201, 202, 203, 211, 221, 222, 241, 242, 251, 252} ;
Recombine Surface {201, 202, 203, 211, 221, 251} ;
Recombine Surface {222, 241, 242, 252} ;

Physical Line(1) = {1,2,3};
Physical Line(2) = {31};
Physical Line(3) = {4};
Physical Line(4) = {14};
Physical Line(5) = {23,43,53};
Physical Line(6) = {11};
Physical Line(7) = {21};
Physical Line(8) = {22};
Physical Line(9) = {32};
Physical Line(10) = {25,45,55};
Physical Line(11) = {24,44,46,54};
Physical Line(12) = {15};
Physical Line(13) = {12};
Physical Line(14) = {13};
Physical Line(15) = {7};

Physical Surface(1) = {201,202,203};
Physical Surface(2) = {211};
Physical Surface(3) = {221,241,251};
Physical Surface(4) = {222,242,243,252};

