////////////////////////////////////// // // // Thickness or sizing optimization // // of a 3-d elastic cantilever // // by the SIMP Method // // // // Ecole Polytechnique // // ANR FF2A3 // // Copyright G. Allaire, A. Kelly // // January 2010 // ////////////////////////////////////// load "msh3" //load "tetgen" load "medit" ofstream compli("LongCantilever3dSIMP.obj") ; string save="LongCantilever3dSIMP"; // Prefix of backup files int niter=50; // Number of iterations int n=5; // Size of the mesh int m=20; real lagrange=1.; // Lagrange multiplier for the volume constraint real lagmin, lagmax ; // Bounds for the Lagrange multiplier int inddico ; real compliance; // Compliance real complianceold; real densityint; real densityold; real volume0; // Initial volume real volume,volume1; // Volume of the current shape real del=0.10; // Filtering Length Scale real exa=1; // Coefficient for the shape deformation string caption; // Caption for the graphics real E=100; // Young modulus real nu=0.3; // Poisson coefficient (between -1 and 1/2) func g1=0; // Applied forces func g2=-100; func g3=0; real penexp=3.0; //Material Penalization Exponent real mov=0.0; real move=1.0; real[int] vviso(21); real[int] vvviso(21); for (int i=0;i<21;i++) { vviso[i]=0.90+i*0.005 ; vvviso[i]=i*0.05; }; ////////////////////////////////////// // Computation of Lame coefficients // ////////////////////////////////////// real lambda=E*nu/((1.+nu)*(1.-2.*nu)); real mu=E/(2.*(1.+nu)); ///////////////////////////////////////////////////// // Lower and upper bounds for the material density // /////////////////////// ///////////////////////////// real hmin=0.001; real hmax=1.0; real hmoy=0.40; func h0=hmoy ; /////////////////////// 1:Dirichlet boundary condition // Domain definition // 2:Neumann boundary or free boundary condition /////////////////////// 3:Non-homogeneous Neumann or applied load border a(t=0,2*pi){x=0.05*cos(t); y=0.05*sin(t);label=101;}; border bd(t=0,1) {x=0.5;y=-1+2*t; label=1;}; border bs(t=0,1) {x=0.5-t;y=1; label=1;}; border bg(t=0,1) {x=-0.5;y=1-2*t; label=1;}; border bi(t=0,1) {x=-0.5+t;y=-1;label=1;}; mesh Th2=buildmesh(bd(m)+bs(m)+bg(m)+bi(m)+a(n)); savemesh(Th2,save+"2D.msh"); fespace Vh22(Th2,P2); fespace Vh02(Th2,P0); Vh02 hcut; Vh22 reg=region; plot(Th2,reg,wait=1,value=true,fill=1); /////////////////////// // Building the mesh // /////////////////////// int[int] rup=[0,200,1,201], rdown=[0,100,1,101]; real zmax=3.0; real zmin=0.0; int nlayers=60; cout<<"mesh in"<0) { penexp=3.0; }; cout <<"Iteration " < volume0) { lagmax = lagrange ; while (volume > volume0) { lagrange = 2*lagrange ; h = hold-(mov*gradJ+lagrange); // h = sqrt(density*hold/lagrange) ; h = min(h,hmax) ; h = max(h,hmin) ; volume=int3d(Th3)(h) ; }; lagmin = lagrange ; }; // if (volume1 == volume0) { lagmin = lagrange ; lagmax = lagrange ; }; /////////////////////////////////////////////////////// // Dichotomy on the value of the Lagrange multiplier // /////////////////////////////////////////////////////// inddico=0; while ((abs(1.-volume/volume0)) > 0.000001) { lagrange = (lagmax+lagmin)*0.5 ; h = hold-(mov*gradJ+lagrange); // h = sqrt(density*hold/lagrange) ; h = min(h,hmax) ; h = max(h,hmin) ; volume=int3d(Th3)(h) ; inddico=inddico+1; if (volume < volume0) {lagmin = lagrange ;} ; if (volume > volume0) {lagmax = lagrange ;} ; }; cout<<"number of iterations of the dichotomy: "< 2d interpolation. // hcut= h(x,y,yy); hxcut=h(yy,y,x); caption="Design CUT z= "+yy+" , Iteration "+iter+", Compliance "+compliance+", Volume="+volume; plot(hxcut,cmm=caption,fill=1,value=false,viso=vvviso,ps=save+iter+"CUT"+i+".eps",wait= 0); } }; if (compliance>complianceold) { cout<<"Step Rejected"< 2d interpolation. // hcut= h(x,y,yy); hxcut=h(yy,y,x); caption="Final Design CUT z= "+yy+" , Iteration "+iter+", Compliance "+compliance+", Volume="+volume; plot(hxcut,cmm=caption,fill=1,value=true,viso=vvviso,wait= 1); } ////////////////////////////////// // Plot of the mesh deformation // ////////////////////////////////// Dh = movemesh3 (Th3,transfo=[x+coef*u,y+coef*v,z+coef*w]); //plot(Dh,wait=0,ps=save+"def.eps"); medit("deformed", Dh); { ofstream file(save+".bb"); file << h[].n << " \n"; int j; for (j=0;j