Mesh.RecombinationAlgorithm = 1; //Blossom
Mesh.Algorithm=6; //Frontal
Mesh.Smoothing=5;

//Box parameters
width = 25;
height = 25;
width_pad = 23;
height_pad = 23;

//radius of the bath particles
r = 1.0;

scale_center = 5e-1;
scale_inner = 5e-1;
scale_tip = 2.5e-1;
scale_contact = 2.5e-1;
scale_outer = 1e0;

//x,y coordinates of the center of the banana
//h the moon parameter as used in ashton
//m radius of the moon particle
Function Moon
	d = 2*m*(1 - h);
	//center
	p0 = newp; Point(p0) = {x,y,0,scale_center};
	//lower center
	p1 = newp; Point(p1) = {x,y-d,0,scale_center};

	//outline
	//tips
	k = Sqrt(m*m - d*d/4);
	p2 = newp; Point(p2) = {x-k,y-d/2,0,scale_tip};
	p3 = newp; Point(p3) = {x+k,y-d/2,0,scale_tip};

	//arc middles, because circle arcs must be smaller than pi
	p4 = newp; Point(p4) = {x,y+m,0,scale_inner};
	p5 = newp; Point(p5) = {x,y-d+m,0,scale_inner};

	//excluded volume
	//outer transition left and right
	ty = -d*(m+r)/2/m;
	tix = (d - 2*m)*(d + 2*m)*(m-r)/(2*m*Sqrt(2*m-d)*Sqrt(2*m+d));
	tox = (d - 2*m)*(d + 2*m)*(m+r)/(2*m*Sqrt(2*m-d)*Sqrt(2*m+d));
	p6 = newp; Point(p6) = {x+tox,y+ty,0,scale_contact};
	p7 = newp; Point(p7) = {x-tox,y+ty,0,scale_contact};

	//arc middles upper and lower
	p8 = newp; Point(p8) = {x,y+m+r,0,scale_contact};
	p9 = newp; Point(p9) = {x,y-d+m-r,0,scale_contact};

	//inner transition left and right
	p10 = newp; Point(p10) = {x+tix,y+ty,0,scale_contact};
	p11 = newp; Point(p11) = {x-tix,y+ty,0,scale_contact};

	//inner
	l0 = newl; Circle(l0) = {p2,p0,p4};
	l1 = newl; Circle(l1) = {p4,p0,p3};
	l2 = newl; Circle(l2) = {p3,p1,p5};
	l3 = newl; Circle(l3) = {p5,p1,p2};

	inner = newll;
	Line Loop(inner) = {l0,l1,l2,l3};

	//contact
	l4 = newl; Circle(l4) = {p6,p0,p8};
	l5 = newl; Circle(l5) = {p8,p0,p7};
	l6 = newl; Circle(l6) = {p7,p3,p11};
	l7 = newl; Circle(l7) = {p11,p1,p9};
	l8 = newl; Circle(l8) = {p9,p1,p10};
	l9 = newl; Circle(l9) = {p10,p2,p6};
	
	contact = newll;
	Line Loop(contact) = {l4,l5,l6,l7,l8,l9};
Return

Function PadBox
	p0 = newp; Point(p0) = {+width,+height,0,scale_outer};
	p1 = newp; Point(p1) = {+width,-height,0,scale_outer};
	p2 = newp; Point(p2) = {-width,-height,0,scale_outer};
	p3 = newp; Point(p3) = {-width,+height,0,scale_outer};

	p4 = newp; Point(p4) = {+width_pad,+height_pad,0,scale_outer};
	p5 = newp; Point(p5) = {+width_pad,-height_pad,0,scale_outer};
	p6 = newp; Point(p6) = {-width_pad,-height_pad,0,scale_outer};
	p7 = newp; Point(p7) = {-width_pad,+height_pad,0,scale_outer};

	//outer
	l0 = newl; Line(l0) = {p0,p1};
	l1 = newl; Line(l1) = {p1,p2};
	l2 = newl; Line(l2) = {p2,p3};
	l3 = newl; Line(l3) = {p3,p0};

	outer = newll;
	Line Loop(outer) = {l0,l1,l2,l3};

	//padding
	l4 = newl; Line(l4) = {p4,p5};
	l5 = newl; Line(l5) = {p5,p6};
	l6 = newl; Line(l6) = {p6,p7};
	l7 = newl; Line(l7) = {p7,p4};

	padding = newll;
	Line Loop(padding) = {l4,l5,l6,l7};
Return
