In the topology optimization, filters are introduced to avoid numerical instabilities. Different filtering techniques may result different discreteness of the final solutions, and sometimes may even contribute to different topologies. In this series of tutorial, you will learn how to implement sensitivity filter and grayscale filter in the top3d program.
In the topology optimization, filters are introduced to avoid numerical instabilities. Different filtering techniques may result different discreteness of the final solutions, and sometimes may even contribute to different topologies. In addition to density filter, in the literatures there are bunch of different filtering schemes. For example, sensitivity filter, morphology based black and white filters, filtering technique using Matlab built-in function conv2, filtering based on Helmholtz type differential equations, Heaviside filter, and grayscale filter. All the filters pursue a simple goal to achieve black-and-white structures. Two of them are chosen, which stand for classic and better performance, as well as easy implementation.

A simple non-linear grayscale filter or intermediate density filter has been proposed by Groenwold to further achieve black-and-white topologies. The implementation of the grayscale filter is by changing the OC update scheme as the following

The standard OC updating method is a special case of equation above with \$latex q=1\$. A typical value of \$latex q\$ for the SIMP-based topology optimization is \$latex q=2\$.

The implementation of the grayscale filter to the code can be done as follows:

[expand title="Step.1: Adding One Input Variable" expanded="true" tag="h5"]

Change line 2 by adding one input variable \$latex q\$ to the program

[matlab firstline="2"]
function top3dgsf(nelx,nely,nelz,volfrac,penal,qmax,rmin)
[/matlab]

[/expand]

[expand title="Step.2: Changing OC subroutine" expanded="true" tag="h5"]

Changing line 85 as follows

[matlab firstline="85"]
xnew = max(0,max(x-move,min(1,min(x+move,(x.*sqrt(-dc./dv/lmid)).^q))));
[/matlab]

[/expand]

[expand title="Step.3: Continuations" expanded="true" tag="h5"]

The factor \$latex q\$ should be increased gradually by adding one line after line 68

[matlab firstline="69"]if loop <= 15, q = 1; else q = min(qmax,1.01*q); end[/matlab]

[/expand]

[expand title="Step.4: Results" expanded="true" tag="h5"]

The default cantilever beam program solved using grayscale filter is shown below (left) compared with those using density filter (right)

[/expand]