////////////////////////////////////// // // // Thickness or sizing optimization // // of a 3-d elastic pylon // // by the SIMP Method // // // // Ecole Polytechnique // // ANR FF2A3 // // Copyright G. Allaire, A. Kelly // // January 2010 // ////////////////////////////////////// load "msh3" load "tetgen" load "medit" ofstream compli("pylon3dSIMP.obj") ; string save="pylon3dSIMP"; // Prefix of backup files int niter=200; // Number of iterations int n=40; // 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=0; func g3=-100; real penexp=5.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.80+i*0.010 ; 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 pylon thickness // /////////////////////// ///////////////////////////// real hmin=0.001; real hmax=1.0; real hmoy=0.25; func h0=hmoy ; /////////////////////// 1:Dirichlet boundary condition // Domain definition // 2:Neumann boundary or free boundary condition /////////////////////// 3:Non-homogeneous Neumann or applied load real x0,x1; real y0,y1; border abd(t=0,1) {x=1;y=-0.5+t; label=1;}; border abt(t=0,1) {x=1-2*t;y=0.5; label=1;}; border abg(t=0,1) {x=-1;y=0.5-t; label=1;}; border abi(t=0,1) {x=-1+2*t;y=-0.5;label=1;}; border bbd(t=0,1) {x=0.5;y=-1.5+3*t; label=2;}; border bbt(t=0,1) {x=0.5-t;y=1.5; label=2;}; border bbg(t=0,1) {x=-0.5;y=1.5-3*t; label=2;}; border bbi(t=0,1) {x=-0.5+t;y=-1.5;label=2;}; border cbd(t=0,1) {x=1;y=-1.5+3*t; label=1;}; border cbt(t=0,1) {x=1-2*t;y=1.5; label=1;}; border cbg(t=0,1) {x=-1;y=1.5-3*t; label=1;}; border cbi(t=0,1) {x=-1+2*t;y=-1.5;label=1;}; border dbd(t=0,1) {x=2;y=-1+2*t; label=1;}; border dbt(t=0,1) {x=2-4*t;y=1; label=1;}; border dbg(t=0,1) {x=-2;y=1-2*t; label=1;}; border dbi(t=0,1) {x=-2+4*t;y=-1;label=1;}; border ebd(t=0,1) {x=1;y=-1+2*t; label=1;}; border ebt(t=0,1) {x=1-2*t;y=1; label=1;}; border ebg(t=0,1) {x=-1;y=1-2*t; label=1;}; border ebi(t=0,1) {x=-1+2*t;y=-1;label=1;}; func XX=x; func YY=y; func ZZ=z; x0=-1.0;x1=1.0; y0=-0.5;y1=0.5; n=20;m=10; mesh postb=square(n,m,[x0+(x1-x0)*x,y0+(y1-y0)*y]); x0=-1.0;x1=1.0; y0=-0.5;y1=0.5; n=20;m=10; mesh posth=square(n,m,[x0+(x1-x0)*x,y0+(y1-y0)*y]); x0=-0.5;x1=0.5; y0=-1.5;y1=1.5; n=10;m=30; mesh postgd=square(n,m,[x0+(x1-x0)*x,y0+(y1-y0)*y]); x0=-1.0;x1=1.0; y0=-1.5;y1=1.5; n=20;m=30; mesh postdd=square(n,m,[x0+(x1-x0)*x,y0+(y1-y0)*y]); x0=-2.0;x1=2.0; y0=-1.0;y1=1.0; n=40;m=20; mesh crossb=square(n,m,[x0+(x1-x0)*x,y0+(y1-y0)*y]); x0=-1.0;x1=1.0; y0=-1.0;y1=1.0; n=20;m=20; mesh crossgd=square(n,m,[x0+(x1-x0)*x,y0+(y1-y0)*y]); x0=-2.0;x1=2.0; y0=-1.0;y1=1.0; n=40;m=20; mesh crossddh=square(n,m,[x0+(x1-x0)*x,y0+(y1-y0)*y]); int[int] refpb=[0,111]; int[int] refph=[0,112]; int[int] refpdev=[0,121]; int[int] refpder=[0,122]; int[int] refpg=[0,131]; int[int] refpd=[0,132]; int[int] refcb=[0,211]; int[int] refch=[0,212]; int[int] refcdev=[0,221]; int[int] refcder=[0,222]; int[int] refcg=[0,231]; int[int] refcd=[0,232]; mesh3 Th3pb=movemesh23(postb,transfo=[XX,YY,0.0],refface=refpb,orientation=-1); mesh3 Th3pd=movemesh23(postgd,transfo=[1.0,XX,YY+1.5],refface=refpd,orientation=1); mesh3 Th3pg=movemesh23(postgd,transfo=[-1.0,XX,YY+1.5],refface=refpg,orientation=-1); mesh3 Th3pdev=movemesh23(postdd,transfo=[XX,0.5,YY+1.5],refface=refpdev,orientation=-1); mesh3 Th3pder=movemesh23(postdd,transfo=[XX,-0.5,YY+1.5],refface=refpder,orientation=1); mesh3 Th3ph=movemesh23(postb,transfo=[XX,YY,3.0],refface=refph,orientation=1); mesh3 Th3cb=movemesh23(crossb,transfo=[XX,YY,3.0],refface=refcb,orientation=-1); mesh3 Th3ch=movemesh23(crossddh,transfo=[XX,YY,5.0],refface=refch,orientation=1); mesh3 Th3cd=movemesh23(crossgd,transfo=[2.0,XX,YY+4.0],refface=refcd,orientation=1); mesh3 Th3cg=movemesh23(crossgd,transfo=[-2.0,XX,YY+4.0],refface=refcg,orientation=-1); mesh3 Th3cdev=movemesh23(crossddh,transfo=[XX,1.0,YY+4.0],refface=refcdev,orientation=-1); mesh3 Th3cder=movemesh23(crossddh,transfo=[XX,-1.0,YY+4.0],refface=refcder,orientation=1); /////////////////////// // Building the mesh // /////////////////////// mesh3 Th33=Th3pb+Th3pd+Th3pg+Th3pdev+Th3pder+Th3cb+Th3ch+Th3cd+Th3cg+Th3cdev+Th3cder; medit("pylon",Th33); mesh3 Th333=Th3pb+Th3ph+Th3pd+Th3pg+Th3pdev+Th3pder; real[int] domain=[0.,0.,1.,66,0.001]; mesh3 Th3=tetg(Th33,switch="paAAQYVVV",nbofregions=1,regionlist=domain); medit("pylontets",Th3); savemesh(Th3,save+".mesh"); cout<<"========================================"< volume0) { lagmax = lagrange ; while (volume > volume0) { lagrange = 2*lagrange ; h = hold-(mov*gradJ+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; cout<<"volume = "< 2d interpolation. hcut= h(x,yy,y); caption="Design CUT z= "+yy+" , Iteration "+iter+", Compliance "+compliance+", Volume="+volume; plot(hcut,cmm=caption,fill=1,value=true,viso=vvviso,wait= 0); } }; if (compliance>complianceold) { cout<<"Step Rejected"< 2d interpolation. hcut= h(x,yy,y); caption="Final Design CUT z= "+yy+" , Iteration "+iter+", Compliance "+compliance+", Volume="+volume; plot(hcut,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