## 5 Cellular Automata Algorithm with Refined Mesh Adaptation  
The effectiveness of any algorithm applied to solve topology optimization problems relies on the computational effort required to obtain the optimal solution in terms of the number of iterations to perform, number of elements used in the structural analysis, number of design variables, and so on. This computational effort can be reduced by introducing a non-regular mesh of finite elements during the iteration process, by adapting the algorithm to perform mesh refinement within selected regions of the design domain. From the numerical point of view, it is not so obvious where and how to apply such refining, and it is generally assumed that this choice is related to the problem under consideration [34]. For example, the regions of stress concentration or the value of the numerical error indicator can suggest the refinement. While performing topology optimization, the attention is focused on the regions where it has to be decided whether design elements become solids or voids, i.e., on the so-called grey regions defined by the refinement indicator \(\gamma_{i}\)[10]:  
\[\gamma_{i}\ =\ (1-d_{i})d_{i}. \tag{9}\]  
According to [10], the value of \(\gamma_{i}\geq 0.16\) indicates the necessity of refinement of the \(i\)th element. Nevertheless, the numerical studies performed have shown that this value can be slightly modified and adjusted to specific examples being considered. It is also possible to choose a different adaptive strategy based on, for example, the values of compliance or stress calculated for design cells. Based on preliminary studies, one can state that the adjustments of the boundary values of the refinement indicator have a more significant influence on the final refinement than the values of physical quantities on which they are defined. It is also worth mentioning that the function in Equation (9) does not need to be a quadratic function, including asymmetry. This issue could be investigated in detail in further research. \begin{table}
\begin{tabular}{l} \hline GET input data \\ SELECT initial mesh—material density field follows FEM discretization \\ SET initial values of design variables \\ SELECT neighborhood type \\ ASSIGN neighbors to each element \\ SELECT values of control parameters \(N_{1}\) and \(N_{2}\) \\ SELECT move limit \(m\) \\ DOUNTIL stopping criteria are met \\ INTRODUCE mesh adaptation if required \\ PERFORM structural analysis—ANSYS solver \\ IMPORT data from structural analysis \\ FOR all elements \\ CALCULATE local compliances \(U_{i}\) \\ END FOR \\ CALCULATE \(\alpha_{i}\) and \(\alpha_{ik}\) \\ FOR all elements \\ UPDATE design variables \(d_{i}\) \\ END FOR \\ IMPOSE volume constraint \\ END DO \\ \hline \end{tabular}
\end{table} 
Table 1: The pseudo-code of the proposed algorithm. Based on the above discussion, the mesh refinement was applied to inner and outer boundaries to improve the quality of the boundary representation. Importantly, it allows grey elements on the boundaries to be avoided, and a solid/void (black-and-white) structure to be obtain, at the same time controlling the mesh resolution. The proposed Cellular Automata approach does not require any additional density filtering to generate solid/void topologies, and the simplest refinement strategy described above is entirely sufficient to meet a condition of smooth boundaries with a very fine mesh. To control the process of the mesh refinement, the principles described, e.g., in [6] and [8] were adopted. The first rule is to keep the element size within the defined range, i.e., the smallest size of elements which can be refined is set. That prevents the creation of very small elements, which bring no improvement to the solution. The next issue is when to apply a refinement. If it is applied too early, after a small number of iterations, a large number of cells will be refined because of a large number of grey elements at this stage. In the end, this causes the profit from the reduction of the total elements number to be low.