# Topology Optimization Considering Porosity Defects in Metal Additive Manufacturing
## 2 Level Set Topology Optimization  
In the level set topology optimization of continuum structure, an optimal design \(\Omega\) is sought in the design domain \(D\), and \(\partial\Omega\) is the boundary of \(\Omega\). The topology of the structure is described by the implicit level set function \(\Phi(\mathbf{x})\) as:  
\[\left\{ \begin{array}{ll}\Phi(x)>0&x\in\Omega\\ \Phi(x)=0&x\in\partial\Omega\\ \Phi(x)<0&x\in D\cap\overline{\Omega}\end{array} \right. \tag{1}\]  
In the problem of maximizing structural stiffness (i.e., minimizing compliance), it is assumed that the constraint condition is the optimized structural volume, and the optimization objective is the compliance. When the load and boundary conditions are given, the topology optimization problem can be described as:  
\[ \begin{array}{ll}\min J(u)=\int_{\Omega}f(u)dx=\int_{\Omega}E\epsilon(u) \cdot\epsilon(v)dx\\ s.t.\,\,\int_{\Omega}E\epsilon(u)\cdot\epsilon(v)dx=\int_{\Omega}Pvdx+\int_{ \partial\Omega}\tau vds\\ \qquad\qquad\qquad\forall v\in U\,\,\,\,\,u|_{\Gamma_{D}}=u_{0}\\ \qquad\qquad\qquad\int_{\Omega}d\Omega=V_{max}\end{array}  \tag{2}\]  
where \(u\) is the displacement field, \(E\) is the elasticity tensor of the material, \(\epsilon\) is the strain tensor, \(P\) is the body force, \(\tau\) is the boundary force, \(\int_{\Omega}d\Omega\) is the volume of the structure, and \(V_{max}\) is the maximum admissible volume. This paper aims to study the topology optimization problem of the linear elastic structure, so the boundary \(\partial\Omega\) of the design domain \(\Omega\) consists of three parts:  
\[\partial\Omega=\Gamma_{0}+\Gamma_{N}+\Gamma_{D} \tag{3}\]  
where \(\Gamma_{D}\) is the Dirichlet boundary conditions and \(\Gamma_{N}\) is the Neumann boundary conditions. Therefore, the linear elastic problem described in (2) is also expressed as:  
\[\left\{ \begin{array}{ll}-div(E\epsilon(u))=P&\Omega\\ u=0&\Gamma_{D}\\ (E\epsilon(u))n=\tau&\Gamma_{N}\\ (E\epsilon(u))n=0&\Gamma_{0}\end{array} \right. \tag{4}\]Then, the objective function based on compliance can be expressed as:  
\[\int_{\Omega}E\epsilon(u)\cdot\epsilon(u)dx=\int_{\Omega}P\cdot udx+\int_{T_{N}} \tau\cdot uds \tag{5}\]  
Employing the level set function \(\Phi(x)\), the level set topology optimization problem is written as follows:  
\[ \begin{array}{rl}\min J(u,\Phi)=\int_{\Omega}f(u)H(\Phi)dx=\int_{\Omega}E \epsilon(u)\cdot\epsilon(u)H(\Phi)dx\\ s.t.\begin{array}{c}a(u,\
u,\Phi)=L(v,\Phi)\\ \forall v\in U\begin{array}{c}u\end{array}\big{|}_{T_{D}}=u_{0}\\ V(\Phi)=V_{max}\end{array}\end{array}  \tag{6}\]  
where \(a(u,\
u,\Phi)\), \(L(v,\Phi)\) and \(V(\Phi)\) are expressed as:  
\[ \begin{array}{c}a(u,\
u,\Phi)=\int_{\Omega}E\epsilon(u)\cdot\epsilon(\
u)H( \Phi)dx\\ L(v,\Phi)=\int_{\Omega}P\
u H(\Phi)dx+\int_{\partial\Omega}\tau v\delta(\Phi) |\
abla\Phi|ds\\ V(\Phi)=\int_{\Omega}H(\Phi)dx\end{array}  \tag{7}\]  
where \(H(\cdot)\)is the Heaviside function, which is defined as:  
\[H(x)=\left\{ \begin{array}{cc}1&x\geq 0\\ 0&x<0\end{array} \right. \tag{8}\]  
\(\delta(\cdot)\) is the Dirichlet function, and its relationship with the Heaviside function is as follows:  
\[\delta(x)=\frac{dH(x)}{dx} \tag{9}\]  
To solve the Hamilton-Jacobi partial differential equation, the concept of shape sensitivity is introduced to calculate the velocity field \(V_{n}\) of the level set function. The Murat and [PERSON] analysis [46] based on the Hadamard variational method was used to calculate shape sensitivity. Considering a smooth initial shape \(\Omega_{0}\), all admissible shapes \(\Omega\) are obtained by applying a smooth vector field \(\theta\):  
\[\Omega=\{x+\theta(x), \begin{array}{c}x\epsilon\Omega_{0}\end{array} \} \tag{10}\]  
The above equation shows that all admissible shapes are represented by a vector \(\theta\), so (10) is also written as:  
\[\Omega=(Id+\theta)(\Omega_{0}) \tag{11}\]  
where \((Id+\theta)\) is the diffeomorphic mapping of \(\Omega_{0}\). Then, the shape sensitivity can be defined by the derivative with respect to \(\theta\).