The SIMP (Solid Isotropic Material with Penalization) is implemented in essentially the same way numerically as the density optimization example above. The difference is that the material density is "penalized" (i.e. the density is raised to some large exponent, say >=3) in order to discourage the formation of intermediate densities (i.e. between 0 and 1) that have no real physical significance in structural optimization. For simple structures such as the long cantilever, which is optimized on a fixed mesh that is shaped as a rectangular prism, the layer mesh capability again proves sufficient to generate the mesh for the Finite Element Method.
The Thick Plate by the SIMP Method
A script for the thick plate by the SIMP Method can be obtained here.
Long Cantilever by the SIMP Method
A script for a long cantilever by the SIMP Method can be obtained here.
A Pylon by the SIMP Method
For more interesting structures (such as a pylon) where layered meshes prove insufficient, the three-dimensional meshing is made possible through FreeFEM's interface with the third-party mesh generator TetGen (by Hang Si, see http://tetgen.berlios.de). A three dimensional surface mesh generated in FreeFEM++ and tetrahedralized by calling the TetGen software.
A script for the Pylon by the SIMP Method can be obtained here (requires TetGen included in current FreeFEM++ releases).