# Topology Optimization Considering Porosity Defects in Metal Additive Manufacturing
## 4 Constraint Function Considering Porosity Defects
### Shape Sensitivities of Porosity Constraints  
The level set method topology optimization needs to solve the shape sensitivity of the objective and the constraint function. The shape sensitivity of the compliance and the volume constraint have been obtained in Section 2. Next, the shape sensitivity of the porosity constraint function will be derived.  
The shape sensitivity of the constraint function is solved by the Cea method. Introducing Augmented Lagrangian:  
\[\begin{array}{c}L(\Omega,u,p)=\frac{1}{2}\int_{\Omega}\Bigl{(}\bigl{[}c_{p}- \eta c_{0}\bigr{]}_{+}\Bigr{)}^{2}dx+\int_{\Omega}E\epsilon(u):\epsilon(p)dx\\ \qquad\qquad-\int_{\Omega}f\cdot pdx-\int_{T_{N}}\delta\cdot pds\end{array} \tag{41}\]  
Under the optimization theory, the stagnation point of the Lagrangian is the optimality condition of the minimization problem. Therefore, the optimal value of the function can be solved by finding the stagnation point of the function. For a given \(\Omega\), \((u_{\Omega},p_{\Omega})\) represents the stagnation point. At first, take the partial derivative of \(L(\Omega,u,p)\) with respect to \(p\):  
\[\frac{\partial L}{\partial p}(\Omega,u,p)=\int_{\Omega}E\epsilon(u):\epsilon( \hat{p})dx-\int_{\Omega}f\cdot\hat{p}dx-\int_{T_{N}}\delta\cdot\hat{p}ds \tag{42}\]  
Let (42) be equal to 0, which is the same as the linear elastic equation in the optimization problem. Therefore, the solution of (42) is equal to the solution of the linear elastic equation, i.e., \(u=u_{\Omega}=u_{\epsilon}\).  
Secondly, take the partial derivative of \(L(\Omega,u,p)\) with respect to u:  
\[\frac{\partial L}{\partial u}(\Omega,u,p)=\int_{\Omega}\bigl{[}c_{p}-\eta c_{0 }\bigr{]}_{+}M(B_{x,r})D_{T}^{\prime}I(\Omega)(\hat{u})dx+\int_{\Omega}E \epsilon(p):\epsilon(\hat{u})dx \tag{43}\]  
Let (43) be equal to 0, suppose its solution is \(p=p_{\Omega}\), which results in:  
\[\int_{\Omega}\bigl{[}c_{p}-\eta c_{0}\bigr{]}_{+}M(B_{x,r})D_{T}^{\prime}I( \Omega)(v)dx+\int_{\Omega}E\epsilon(p_{\Omega}):\epsilon(v)dx=0 \tag{44}\]  
The shape sensitivity of the constraint function can be obtained by differentiating \(C_{p}(\Omega)=L(\Omega,u,p)\). According to the chain derivation rule, the shape sensitivity of the objective function can be obtained as:  
\[C_{p}^{\prime}(\Omega)(\theta)=\frac{\partial L}{\partial\Omega}(\Omega,u,p) (\theta)+\frac{\partial L}{\partial u}(\Omega,u,p)\bigl{(}u^{\prime}(\theta) \bigr{)} \tag{45}\]  
Substituting \((u_{\Omega},p_{\Omega})\) into (45), the second term \(\frac{\partial L}{\partial u}(\Omega,u_{\Omega},p_{\Omega})\) on the right side of (45) is equal to 0, so the shape sensitivity of the constraint function is:  
\[C_{p}^{\prime}(\Omega)(\theta)=\frac{\partial L}{\partial\Omega}(\Omega,u_{ \Omega},p_{\Omega})(\theta) \tag{46}\]  
Quoting Lemma 4 and Lemma 5 in [20], the result is:  
\[\begin{array}{c}\frac{\partial L}{\partial\Omega}(\Omega,u_{\Omega},p_{ \Omega})(\theta)=\frac{1}{2}\int_{\Omega}\Bigl{(}\bigl{[}c_{p}-\eta c_{0} \bigr{]}_{+}\Bigr{)}^{2}\theta\cdot nds\\ \qquad\qquad+\int_{\Omega}\Bigl{(}\bigl{[}c_{p}-\eta c_{0}\bigr{]}_{+}\Bigr{)} M(B_{x,r})D_{T}^{\prime}I(\Omega  
where  
\[\begin{array}{ll}\text{for }d=2\\ \begin{array}{ll}D_{T}^{\prime}J(\Omega)(v)=&8\mu\frac{\pi(\lambda+2\mu)}{2\mu( \lambda+\mu)}Ee(u):\epsilon(v)\\ &+2(\lambda-\mu)\frac{\pi(\lambda+2\mu)}{2\mu(\lambda+\mu)}T(Ee(u))T(\epsilon(v ))\end{array}\end{array} \tag{50}\]  
for \(d=3\)  
\[\begin{array}{ll}D_{T}^{\prime}J(\Omega)(v)=&40\mu\frac{\pi(\lambda+2\mu)}{ \mu(\lambda+14\mu)}E\epsilon(u):\epsilon(v)\\ &+2(3\lambda-2\mu)\frac{\pi(\lambda+2\mu)}{\mu(\lambda+14\mu)}T(Ee(u))T( \epsilon(v))\end{array} \tag{51}\]