// characteristic length, size
lc = .01;
ls = .01;

// front surface
P01 = newp; Point(P01) = {0., 0., 0., lc};
P02 = newp; Point(P02) = {ls, 0., 0., lc};
P03 = newp; Point(P03) = {ls, ls/2., 0., lc};
P08 = newp; Point(P08) = {0., ls/2., 0., lc};

// back surface
P09 = newp; Point(P09) = {ls, 0., ls, lc};
P10 = newp; Point(P10) = {ls, ls/2, ls, lc};
P15 = newp; Point(P15)  = {0., ls/2., ls, lc};
P16 = newp; Point(P16)  = {0., 0., ls, lc};

//reorder lines numbers in increasing consecutive order
// front surface
L01 = newl; Line(L01) = {P01, P02};
L02 = newl; Line(L02) = {P02, P03};
L08 = newl; Line(L08) = {P08, P01};
L09 = newl; Line(L09) = {P03, P08};

// back surface
L11 = newl; Line(L11) = {P09, P10};
L17 = newl; Line(L17) = {P15, P16};
L18 = newl; Line(L18) = {P16, P09};
L19 = newl; Line(L19) = {P10, P15};

// right side surface
L21 = newl; Line(L21) = {P02, P09};
L22 = newl; Line(L22) = {P03, P10};

// left side surface
L25 = newl; Line(L25) = {P01, P16};
L26 = newl; Line(L26) = {P08, P15};

// number points per line
nppl_bottom =  3;

// uniform distribution, overrides any predefined characteristic length

// bottom surface - LL01, LL04, LL07, LL10, LL13, LL15
// LL01 - {L01, L02, -L09, L08}; LL04 - {L11, L19, L17, L18}
// LL07 - {-L02, L21, L11, -L22}; LL10 - {L08, L25, -L17, -L26}
// LL13 - {L01, L21, -L18, -L25}; LL15 - {-L09, L22, L19, -L26}
// Distinct Lines: L01, L02, L08, L09, L11, L17, L18, L19, L21,
//                 L22, L25, L26

Transfinite Line{L01} = nppl_bottom;
Transfinite Line{L02} = nppl_bottom;
Transfinite Line{L08} = nppl_bottom;
Transfinite Line{L09} = nppl_bottom;
Transfinite Line{L11} = nppl_bottom;
Transfinite Line{L17} = nppl_bottom;
Transfinite Line{L18} = nppl_bottom;
Transfinite Line{L19} = nppl_bottom;
Transfinite Line{L21} = nppl_bottom;
Transfinite Line{L22} = nppl_bottom;
Transfinite Line{L25} = nppl_bottom;
Transfinite Line{L26} = nppl_bottom;

// create line loops
// counter clockwise orientation as viewed from outside

// front surfaces (bottom PS1, middle PS2, top PS3)
LL01 = newll;
Line Loop(LL01) = {L01, L02, L09, L08};

// back surface (bottom PS4, middle PS5, top PS6)
LL04 = newll;
Line Loop(LL04) = {L11, L19, L17, L18};

// right side surface (bottom PS7, middle PS8, top PS9)
LL07 = newll;
Line Loop(LL07) = {-L02, L21, L11, -L22};

// left side surface (bottom PS10, middle PS11, top PS12)
LL10 = newll;
Line Loop(LL10) = {L08, L25, -L17, -L26};

// bottom side surface (PS13)
LL13 = newll;
Line Loop(LL13) = {L01, L21, -L18, -L25};

// mid 1 surface (PS15)
LL15 = newll;
Line Loop(LL15) = {-L09, L22, L19, -L26};

//need to finish point distributions and surface creation

// create surfaces
// bottom to top
// front
// bottom surface (PS1)
PS1 = news;
Plane Surface(PS1) = {LL01};

// back
// bottom surface (PS4)
PS4 = news;
Plane Surface(PS4) = {LL04};

// right side
// bottom surface (PS7)
PS7 = news;
Plane Surface(PS7) = {LL07};

// left side
// bottom surface (PS10)
PS10 = news;
Plane Surface(PS10) = {LL10};


// bottom surface (PS13)
PS13 = news;
Plane Surface(PS13) = {LL13};

// mid 1 surface (PS15)
PS15 = news;
Plane Surface(PS15) = {LL15};

//define transfinite surfaces from plane surfaces
/*
Transfinite Surface{PS1}  = {P01, P02, P03, P08};
Transfinite Surface{PS4}  = {P09, P16, P15, P10};
Transfinite Surface{PS7}  = {P02, P09, P10, P03};
Transfinite Surface{PS10} = {P01, P16, P15, P08};
Transfinite Surface{PS13} = {P01, P02, P09, P16};
Transfinite Surface{PS15} = {P03, P08, P10, P15};
*/
Transfinite Surface '*';


// define surface loops
SL1 = newsl;
Surface Loop(SL1) = { PS1, PS7, PS4, PS10, PS13, PS15 };
V1 = newv;
Volume(V1) = { SL1 };

/*
// define Transfinite Volume
Transfinite Volume{V1} = {P01, P02, P03, P08, P09, P10, P15, P16};
*/

Transfinite Volume '*';


