//////////////////////// PARAMETERS //////////////////////////// verbosity=0; macro g [1.,0.] // Applied surface load real Y=15; // Young Modulus real nu=0.35; // Poisson Ratio real lambda=Y*nu/((1.+nu)*(1.-2.*nu)); // Lame Moduli real mu=Y/(2.*(1.+nu)); int Niter=50; // Number of iterations real GeoPrec=0.3; // scale of the geometric mesh real step=0.1; // initial descent step real penVolume=0.04 ; real penCompliance=5.; real maxstep=100.; /////////////////////////////////////////// //// Definition of the initial mesh //// /////////////////////////////////////////// int Gamma,Gammap,GammaN,GammaD,GammaD0; // Labels for optimized boundaries, Neumann and Dirichlet condidtions {Gamma=1;Gammap=2;GammaN=3;GammaD=4;GammaD0=8;}; int FreezeX,FreezeY,FreezeXY; // Freeze degree of freedom of theta {FreezeX=5;FreezeY=6;FreezeXY=7;} mesh Sh; // The Total mesh real L,LD,Lgrip,Hgrip,D; // length of the grip, Half-Length of the Dirichlet BC part, Length/Height of the "gripping" part, Half Width of the grip { // The definition of the initial mesh could be modified as will // // -- a grip LD=0.5;L=6;Lgrip=0.5;Hgrip=0.25;D=3; real Hg=0.25; real deltax=1.,deltay=1.; int n=5; border Left0(t=0,1){x=-t*(L/2.-LD)+L/2.-LD;y=t*(Hg-D)+D; ;label=Gamma;}; border Left1(t=Hg,-Hg){x=0;y=t;label=GammaN;}; border Left2(t=1,0){x=-t*(L/2.-LD)+L/2.-LD;y=-t*(Hg-D)-D; ;label=Gamma;}; border Bottom0(t=L/2.-LD,L/2.-LD+LD/5.){x=t;y=-D;label=GammaD0;}; border Bottom(t=L/2.-LD+LD/5.,L/2.+LD){x=t;y=-D;label=GammaD;}; border Right0(t=0,1){x=t*(L/2.-LD)+L/2.+LD;y=t*(D-Hgrip)-D;label=Gamma;}; border Grip0(t=L,L-Lgrip){x=t;y=-Hgrip;label=Gammap;}; border Grip1(t=-Hgrip,Hgrip){x=L-Lgrip;y=t;label=FreezeXY;}; border Grip2(t=L-Lgrip,L){x=t;y=Hgrip;label=Gammap;}; border Right1(t=1,0){x=t*(L/2.-LD)+L/2.+LD;y=-t*(D-Hgrip)+D;label=Gamma;}; border Top(t=L/2.+LD,L/2.-LD+LD/5.){x=t;y=D;label=GammaD;}; border Top0(t=L/2.-LD+LD/5.,L/2.-LD){x=t;y=D;label=GammaD0;}; border Hole1(t=0,2.*pi){x=cos(t)*L/5.+L/2.;y=sin(t)*L/5.;label=Gamma;} // -- BIG BOX containing the shape --// border DLeft(t=D+deltay,-D-deltay){x=-deltax;y=t;label=FreezeX;}; border DBottom(t=-deltax,L+deltax){x=t;y=-D-deltay;label=FreezeY;}; border DRight(t=-D-deltay,D+deltay){x=L+deltax;y=t;label=FreezeX;}; border DTop(t=L+deltax,-deltax){x=t;y=D+deltay;label=FreezeY;}; Sh=buildmesh( DLeft(2*D*n)+DBottom(L*n)+DRight(2*D*n)+DTop(L*n) +Left0(D*n)+Left1(n*Hg)+Left2(D*n)+Bottom0(1)+Bottom(LD*n) +Right0(D*n)+Grip0(Lgrip*n)+Grip1(Hgrip*n)+Grip2(Lgrip*n) +Right1(D*n)+Top(LD*n)+Top0(1)+Hole1(10) ); plot(Sh,wait=1); } mesh Th; // The mesh of the shape int ShapeLabel; // Region label of the shape fespace Zh(Sh,P0); Zh reg; // Region labels { real px=0.01; real py=0.; // a point of the shape reg=region; ShapeLabel=reg(px,py); Th=trunc(Sh,reg==ShapeLabel); plot(Th,wait=1); } //////////////////////////////////////// // end of initial mesh definition // //////////////////////////////////////// plot(Th,wait=1);