1 Introduction

When there are higher velocities in the fluid flow (i.e., higher Reynolds numbers), a turbulent behavior may be induced. The turbulent behavior is characterized for being chaotic, diffusive, dissipative, and intermittent (Saad 2007), and is present in most flows in nature. In order to model the turbulent behavior, there are essentially three approaches: DNS (Direct Numeric Simulation) (Orszag 1970), LES (Large Eddy Simulation) (Smagorinsky 1963; Deardorff 1970), and RANS (Reynolds-Averaged Navier–Stokes) (Reynolds 1895). The first approach (DNS) consists of considering the Navier–Stokes equations with a mesh resolution that is capable of considering the smallest scale vortices, which poses a high computational cost, while the second approach (LES) poses a somewhat smaller computational cost due to it filtering smaller scale vortices. However, the RANS approach poses a lower computational cost in relation to DNS and LES, due to it considering statistical time-averaging, which leads to the possibility of considering a coarser mesh in RANS with respect to DNS/LES (Celik 2003).

The topology optimization method applied for fluid flow is an optimization method that relies on spatially distributing the design variable that defines the solid/fluid material throughout a given design domain. It initially started with simpler flows (Stokes flows) (Borrvall and Petersson 2003), but was extended in the following years to more complex flow physics, such as Navier–Stokes flows (Evgrafov 2004; Olesen et al. 2006), non-Newtonian flows (Pingen and Maute 2010; Hyun et al. 2014; Romero and Silva 2017), thermal-fluid flows (Sato et al. 2018; Ramalingom et al. 2018), unsteady flows (Nørgaard et al. 2016), turbulent flows (Papoutsis-Kiachagias et al. 2011; Yoon 2016; Dilgen et al. 2018; Yoon 2020; Sá et al. 2021), etc. Specific applications have also been considered such as rectifiers (Jensen et al. 2012), valves (Song et al. 2009), mixers (Andreasen et al. 2009), and flow machine rotors (Romero and Silva 2014; Sá et al. 2018; Alonso et al. 2019; Sá et al. 2021). The topology optimization method may be implemented in various forms such as the “pseudo-density approach” (Borrvall and Petersson 2003), the “level-set method” (Duan et al. 2016; Zhou and Li 2008), and topological derivatives (Sokolowski and Zochowski 1999; Sá et al. 2016). The “pseudo-density approach” is the one considered in this work, and is based on the inclusion of an interpolation function between the solid and fluid materials. When considering topology optimization with the “pseudo-density approach,” the design variable may be considered in different ways by the optimizer: the continuous approach, which allows the appearance of intermediary (“gray”) design variable values during topology optimization (such as MMA (Method of Moving Asymptotes) (Svanberg 1987) and IPOPT (Interior Point Optimization) (Wächter and Biegler 2006)), and the discrete approach, which allows the design variable to assume only one of two states (solid (0) or fluid (1)) (such as TOBS (Sivapuram and Picelli 2018; Sivapuram et al. 2018; Souza et al. 2021)). Using a discrete approach allows the design variable to be always discrete, meaning that it may become easier to achieve a discrete optimized topology than the continuous approach. Therefore, in this work, the discrete approach is considered, in the form of the TOBS algorithm.

One of the current challenges in fluid topology optimization is to address high Reynolds number flows (i.e., turbulent flows) such that industrial or more realistic fluid flow devices can be designed. This means that there is a need for considering turbulence models in more efficient ways into the topology optimization framework. The topology optimization of turbulent flows is mostly centered around RANS models, due to their reduced computational cost with respect to DNS/LES. The first turbulence model to be considered in topology optimization is the one-equation Spalart–Allmaras model (Spalart and Allmaras 1994), which does not require overly high resolution in wall-bounded flows with respect to two-equation turbulent models (Bardina et al. 1997) and also shows good convergence for simple flows (Bardina et al. 1997). In topology optimization, the Spalart–Allmaras equations are changed in order to take the solid material modeling into account (Papoutsis-Kiachagias et al. 2011; Kontoleontos et al. 2013; Papoutsis-Kiachagias and Giannakoglou 2016; Yoon 2016). The Spalart–Allmaras equation relies on the computation of the wall distance, which changes during topology optimization according to the design variable, meaning that this sensitivity also needs to be included in the turbulent flow topology optimization formulation. The wall distance can be considered by the solution of a modified Eikonal equation (Yoon 2016) or a stabilized Eikonal equation (Sá et al. 2021). Two equation turbulent models (kε and kω) have also been considered (Dilgen et al. 2018; Yoon 2020). One problem these turbulence models face is the amount of parameters that have to be adjusted for topology optimization besides the additional coefficient in the Navier–Stokes equations: in the case of the Spalart–Allmaras model, there are two additional coefficients (in the Spalart–Allmaras equation, and in the wall distance equation) (Yoon 2016); in the kε and kω models, there are also two additional coefficients (one for the equation of each variable, although some authors may try to simplify by a single additional coefficient) (Dilgen et al. 2018; Yoon 2020). From a combinatorial point of view, by considering that each coefficient amounts for “\(n_\text {pv}\)” possible values for topology optimization, the total amount of coefficients to be considered (in the three sets of equations: the Navier–Stokes equations, and the two equations required for the turbulent model) becomes elevated to the third power (“\(n_\text {pv}^3\)”). It can be reminded that although an empirical rule based on the Darcy number (Dilgen et al. 2018) can be used for the coefficient of the Navier–Stokes equations, it is not definitive, and higher or lower coefficient values may be necessary depending on the fluid flow problem. This means that adjusting these coefficients for topology optimization would rely on a “trial and error” approach, and may become a hassle the higher the quantity of adjustable topology optimization coefficients. It can also be mentioned that some topology optimization configurations may require finding specific coefficient values that are able to achieve a feasible and discrete optimized topology, which may not be easy to perform depending on the problem. In order to face this problem, it would be better for topology optimization if the turbulent model could be as simple as the Spalart–Allmaras model (i.e., a single-equation model that does not require the use of a wall function), not require the computation of the wall distance, and also achieve simulation results that approach simulations from the kε and kω models, which are often considered in the CFD community.

The Wray–Agarwal model is a single-equation turbulence model (similarly to the Spalart–Allmaras model), which combines the advantages of the kω model (“near-wall” modeling) and the kε model (“freestream” modeling). It is also partly based on the SST kω model. According to Wray and Agarwal (2015), the Wray–Agarwal model can lead to more accurate boundary layer separation predictions than the Spalart–Allmaras model, and it is also said to be competitive with the SST kω model for wall-bounded flows. The 2018 version of the Wray–Agarwal model (“WA2018”) is presented in Han et al. (2018), and its main advantage is that this variant does not require the computation of the wall distance. This fact alone means that less optimization parameters are needed to be calibrated “by hand” for topology optimization. Furthermore, since, in topology optimization, it is required to perform the computation of the forward model (i.e., the simulation) and the computation of the adjoint model, the matrix systems of equations to be solved are, when considering the Wray–Agarwal model (“WA2018”), less in quantity or smaller than the other mentioned turbulence models (when considering the forward and adjoint models), meaning that the Wray–Agarwal model (“WA2018”) would be less computationally demanding in a topology optimization iterative framework. Therefore, the Wray–Agarwal model (“WA2018”) is considered in this work. It can be highlighted that no previous work has considered the Wray–Agarwal model in topology optimization. In addition, the topology optimization implementation is performed by considering discrete design variable configurations, based on the TOBS approach. The TOBS approach enforces a binary variables solution through a linearization, which makes it possible to achieve clearly defined topologies (solid–fluid), while also lessening the dependency of the material model penalization in the topology optimization iterations (Souza et al. 2021).

When the fluid flow is characterized by an axisymmetric flow with a rotation around an axis (swirl flow), the fluid flow may be modeled by a “2D swirl flow model,” which is capable of modeling, for example, hydrocyclones, some pumps and turbines, and fluid separators. The main advantage of this type of model is that it simplifies the complete 3D fluid flow model (which is more computationally expensive), reducing the computational cost by using a 2D axisymmetric mesh. It can be highlighted that topology optimization has still not been applied to turbulent 2D swirl flow.

Therefore, the main objectives of this work are to include the turbulent flow modeling (Wray–Agarwal model) in the 2D swirl flow topology optimization formulation, and also to consider the TOBS approach (Sivapuram and Picelli 2018; Sivapuram et al. 2018). The objective of the optimization is to minimize the relative energy dissipation considering the viscous, turbulent, porous, and inertial effects (Borrvall and Petersson 2003; Yoon 2016; Alonso et al. 2019). The traditional material model of fluid topology optimization (Borrvall and Petersson 2003) is adopted by considering nodal design variables, which enables the use of a PDE-based pseudo-density filter with the TOBS approach. It can be reminded that an element-wise design variable would not feature a first derivative, which is a requirement for considering the Helmholtz pseudo-density filter formulation.

This paper is organized as follows: in Sect. 2, the fluid flow model for the turbulent 2D swirl flow is briefly derived; in Sect. 3, the topology optimization problem is stated by considering the Brinkman model; in Sect. 5, the numerical implementation is briefly described; in Sect. 6, some numerical examples are presented; and in Section 7, some conclusions are inferred.

2 Equilibrium equations

The fluid flow is modeled from the continuity and linear momentum (Navier–Stokes) equations, incompressible fluid, steady-state regime, and a turbulent model considered through a RANS (Reynolds-Averaged Navier–Stokes) approach.

2.1 2D swirl flow model

When considering a rotating reference frame, the continuity and Navier–Stokes equations according to the Brinkman model become (Munson et al. 2009; White 2011; Romero and Silva 2014)

$$\begin{aligned} \nabla {\small {\cdot }} {\varvec{v}} = 0 \end{aligned}$$
(1)
$$\begin{aligned} \begin{aligned} \rho \nabla {\varvec{v}} {\cdot } {\varvec{v}} \,=\,&\nabla {\cdot }({\varvec{T}} + {\varvec{T}}_R) + \rho {\varvec{f}} - 2\rho ({\varvec{\omega }}{\wedge }{\varvec{v}}) - \rho {\varvec{\omega }}{\wedge }({\varvec{\omega }}{\wedge }{\varvec{r}})\\&- \kappa (\alpha ) {\varvec{v}}_\text {mat} \end{aligned} \end{aligned},$$
(2)

where \({\varvec{v}}\) is the relative statistical time-averaged velocity of the fluid flow, p is the statistical time-averaged pressure of the fluid flow, \(\rho\) is the fluid density, \(\mu\) is the dynamic viscosity of the fluid, \(\rho {\varvec{f}}\) is the body force per unit volume acting on the fluid, \({\varvec{r}}\) is radial position in the fluid with respect to the rotation axis (in 2D swirl flow, it is equivalent to use \({\varvec{s}}\) (position of the fluid)), \({\wedge }\) is used to denote cross product, \(- \kappa (\alpha ) {\varvec{v}}_\text {mat}\) is the resistance force of the porous medium considered in topology optimization, \(\kappa (\alpha )\) is called inverse permeability (“absorption coefficient”), \({\varvec{v}}_{\text {mat}}\) is the velocity of the fluid in relation to the porous material (in 2D swirl flow, \({\varvec{v}}_{\text {mat}} = (v_{r},\ v_\theta - \omega _{\text {mat}}r,\ v_{z})\), where \(\omega _{\text {mat}}\) is the rotation of the porous material relative to the reference frame)), \(\alpha\) is the pseudo-density, which may achieve values given as 0 (solid) or 1 (fluid) (and is the design variable in topology optimization), \({\varvec{T}}_R\) is the Reynolds (turbulent) stress tensor from the RANS model being considered, and \({\varvec{T}}\) is the fluid stress tensor given by

$$\begin{aligned} \ \ \ \ \ {{\varvec{T}} = 2\mu {\varvec{\epsilon }} - p{\varvec{I}}} , {{\varvec{\epsilon }} = \frac{1}{2}\left( \nabla {\varvec{v}} + \nabla {{\varvec{v}}}^{T}\right) } \end{aligned}.$$
(3)

The 2D swirl flow model (“2D axisymmetric model with swirl”) is based on the considerations of axisymmetrical flow and cylindrical coordinates (see Fig. 1), which means that the position and velocity are given by

$$\begin{aligned} {\varvec{s}} = (r,\ 0,\ z) = r{\varvec{e}}_{r} + z{\varvec{e}}_{z} \end{aligned}$$
(4)
$$\begin{aligned} {\varvec{v}} = (v_{r},\ v_{\theta },\ v_{z}) = v_{r}{\varvec{e}}_{r} + v_{\theta }{\varvec{e}}_{\theta } + v_{z}{\varvec{e}}_{z} \end{aligned}.$$
(5)
Fig. 1
figure 1

Representation of the 2D swirl flow model

From considering axisymmetry, the derivatives of the state variables (\({\varvec{v}}\) and p) in the \(\theta\) direction are set to zero (i.e., \(\frac{\partial v_r}{\partial \theta } = \frac{\partial v_{\theta }}{\partial \theta } = \frac{\partial v_z}{\partial \theta } = \frac{\partial p}{\partial \theta } = 0\)). Also, the definitions of the differential operators (i.e., gradient, divergent and curl) are given in cylindrical coordinates.

2.2 Wray–Agarwal turbulence model

The Wray–Agarwal turbulence model is a single-equation turbulence RANS model, which consists of a combination of the advantages of the near-wall modeling from the k\(\omega\) model with the freestream modeling from the k\(\varepsilon\) model (Wray and Agarwal 2015), being also partly based on the SST k\(\omega\) model (Wray and Agarwal 2015). Wray and Agarwal (2015) show that the Wray–Agarwal turbulence model leads to more accurate boundary layer separation predictions than the Spalart–Allmaras model, and that it is also competitive with the SST k\(\omega\) model for wall-bounded flows. Throughout the years, several evaluations, improvements, and variations have been developed (Han et al. 2015; Wray and Agarwal 2016; Zhang et al. 2016; Han et al. 2017, 2018). Particularly in this work, the 2018 version (referred in Han et al. (2018) as “WA2018”) is considered. The main advantage of the 2018 version is that it does not rely on the computation of the wall distance. Not needing to compute the wall distance is advantageous in a topology optimization point of view, because the wall distance computation requires an additional penalization term (Yoon 2016) in order to account for the modeled solid material, which needs to be calibrated (i.e., adequately chosen) for obtaining the optimized topology. An additional term to account for the attenuation of turbulence in the porous medium is included in this work by re-deducing the Wray–Agarwal model equations while including the attenuation of turbulence in the k\(\omega\) model equations (in a similar fashion as Yoon (2016), Papoutsis-Kiachagias and Giannakoglou (2016), and Dilgen et al. (2018)). Therefore, the Wray–Agarwal model (2018) (Han et al. 2018) modified for topology optimization becomes

$$\begin{aligned} {\varvec{T}}_R = \mu _\text {T} (\nabla {\varvec{v}} + \nabla {{\varvec{v}}}^{T}) \text {, } {\mu _\text {T} = \rho f_{\mu } {R_\text {T}}} \end{aligned}$$
(6)
$$\begin{aligned} \begin{aligned}&\rho {\varvec{v}}{\cdot }\nabla {R_\text {T}} = \underbrace{\nabla \cdot [(\sigma _R \rho R_\text {T} + \mu ) \nabla R_\text {T}]}_{\begin{array}{c} \text {Turbulence transport by}\\ \text {viscous and turbulent stresses} \end{array}}\\&\underbrace{ + \rho C_1 R_\text {T} S}_{\text {Turbulence production}} \underbrace{ + f_1 C_{1,k{-}\omega }\rho \frac{R_\text {T}}{S} {\nabla R_\text {T}}{\cdot }{\nabla S}}_{\begin{array}{c} \text {Near-wall}\,\, (``k-\omega")\\ \text {turbulence destruction} \end{array}}\\&\underbrace{ - \rho (1 - f_1) \min \left[ C_{2,k{-}\varepsilon } R_\text {T}^2 \left( \frac{{\nabla S}{\cdot }{\nabla S}}{S^2} \right) ,\ C_m {\nabla R_\text {T}}{\cdot }{\nabla R_\text {T}} \right] }_{\text {Freestream} \,\,(``k-\varepsilon") \,\, {\text {turbulence destruction}}}\\&\underbrace{ - \lambda _{R_\text {T}} \kappa (\alpha ) R_\text {T}}_{\begin{array}{c} \text {Turbulence attenuation}\\ \text {in the porous medium} \end{array}} \end{aligned} \end{aligned},$$
(7)

where \(R_\text {T}\) is the undamped eddy (turbulent) viscosity, and \(\lambda _{R_\text {T}}\) is an adjustable parameter for the intensity of the attenuation of turbulence inside the modeled solid material. The other terms of Eq. (7) are specified as follows (Han et al. 2018):

$$\begin{aligned} \begin{aligned}&{\varvec{S}} = \frac{1}{2}(\nabla {\varvec{v}} + \nabla {\varvec{v}}^T) {, } S = \sqrt{2 {\varvec{S}}{\cdot }{\varvec{S}}}\\&{\varvec{W}} = \frac{1}{2}(\nabla {\varvec{v}} - \nabla {\varvec{v}}^T) {, } W = \sqrt{2 {\varvec{W}}{\cdot }{\varvec{W}}}\\&f_\mu = \frac{\chi ^3}{\chi ^3 + c_w^3} {, } \chi = \frac{R_\text {T}}{\nu }{, } c_w = 8.54\\&\eta = S \max \left[ 1,\ \left| {\frac{W}{S}}\right| \right] {, } C_m = 8.0\\&\sigma _R = f_1(\sigma _{k{-}\omega } - \sigma _{k{-}\varepsilon }) + \sigma _{k{-}\varepsilon } {, } \sigma _{k{-}\varepsilon } = 1.0 {, } \sigma _{k{-}\omega } = 0.72\\&f_1 = \tanh ({arg}_1^4)\\&{arg}_1 = \frac{\nu + R_\text {T}}{2}\frac{\eta ^2}{C_\mu \left. k_{T}\right| _{\text {log{-}layer}} \left. \omega _{T}\right| _{\text {log{-}layer}}}\\&\left. k_{T}\right| _{\text {log{-}layer}} = \frac{\nu _T S}{\sqrt{C_\mu }} {, } \left. \omega _{T}\right| _{\text {log{-}layer}} = \frac{S}{\sqrt{C_\mu }} {, } C_\mu = 0.09\\&C_1 = f_1 (C_{1,k{-}\omega } - C_{1,k{-}\varepsilon }) + C_{1,k{-}\varepsilon }\\&C_{2,k{-}\omega } = \frac{C_{1,k{-}\omega }}{\kappa ^2} + \sigma _{k{-}\omega } {, } C_{2,k{-}\varepsilon } = \frac{C_{1,k{-}\varepsilon }}{\kappa ^2} + \sigma _{k{-}\varepsilon }\\&C_{1,k{-}\omega } = 0.0829 {, } C_{1,k{-}\varepsilon } = 0.1284\\ \end{aligned} \end{aligned},$$
(8)

where \(\kappa = 0.41\) is the von Kármán constant, and \(\nu = \frac{\mu }{\rho }\) is the kinematic viscosity.

It can be noticed that the term that accounts for the attenuation of turbulence in the porous medium in Eq. (7) assumes that, inside a modeled solid material, RT = 0 m2/s.

With respect to the additional parameter \(\lambda _{R_\text {T}}\), it may be noticed that it is similar to the penalization parameters included in other turbulence models for topology optimization (Yoon 2016; Dilgen et al. 2018; Yoon 2020). Although some references assume all additional penalization parameters as being equal to 1, this may not always be the best choice, since the topology optimization may behave better for a higher or a lower value. In fact, in the present work, the optimized topologies from the Appendices consider values that are higher than 1. Also, in the case of two-equation models, such as the k\(\omega\) model, it is unknown if the same coefficient should really be used for the k and \(\omega\) equations. Experimentally, the turbulence coefficients of these equations are different, which means that these two equations should probably be penalized differently. This effect may be “shadowed” by highly penalizing both equations, but the problem should still remain and may possibly affect the topology optimization iterations. For the case of the Spalart–Allmaras model, it may be mentioned that the penalization parameter is chosen differently than 1 in Yoon (2016), and that the additional penalization parameter of the modified Eikonal equation has to be calibrated for the given problem and is normally not set as equal to 1 (Yoon 2016). In some problems, it may be better to consider a “stronger” modeled solid material wall, while it may be better to relax it in other cases. Moreso, depending on the distribution of the design variable, it may be necessary to increase the “relaxation term” that is shown in Yoon (2016), for allowing convergence.

2.3 Boundary value problem

A computational domain is illustrated in Fig. 2 for showing the boundaries that are considered in this work. The boundary value problem for the 2D swirl flow model can then be stated as follows:

$$\begin{array} {*{20}l} \rho \nabla {\varvec{v}}{\cdot }{\varvec{v}} = \nabla {\cdot }({\varvec{T}} + {\varvec{T}}_R) + \rho {\varvec{f}} - 2\rho ({\varvec{\omega }}{\wedge }{\varvec{v}}) \\ \quad -\rho {\varvec{\omega }}{\wedge }({\varvec{\omega }}{\wedge }{\varvec{r}}) - \kappa (\alpha ){\varvec{v}}_\mathrm {mat}\quad \text { in } \mathrm {\Omega }\\ \nabla {\cdot }{\varvec{v}} = 0\quad \text { in } \mathrm {\Omega }\\ \rho {\varvec{v}}{\cdot }\nabla {R_\mathrm {T}} = \nabla \cdot [(\sigma _R \rho R_\mathrm {T} + \mu ) \nabla R_\mathrm {T}]\\ \quad + \rho C_1 R_\mathrm {T} S+ f_1 C_{1,k\text {-}\omega }\rho \frac{R_\mathrm {T}}{S} {\nabla R_\mathrm {T}}{\cdot }{\nabla S}\\ \quad - \rho (1 - f_1) \min\, \left[ C_{2,k\text {-}\varepsilon } R_\mathrm {T}^2 \left( \frac{{\nabla S}{\cdot }{\nabla S}}{S^2} \right) ,\ \right. \\ \qquad C_m {\nabla R_\mathrm {T}}{\cdot }\, {\nabla R_\mathrm {T}} \left. \right] - \lambda _{R_\mathrm {T}} \kappa (\alpha ) R_\mathrm {T}\quad \text { in } \mathrm {\Omega }\\ {\varvec{v}} = {\varvec{v}}_{in} \text { and } {R_\mathrm {T}}= {R_{\mathrm {T}, in}} \quad \text { on } \mathrm {\Gamma }_{\text {in}}\\ {\varvec{v}} = {\varvec{0}} \text { and } {R_\mathrm {T}}= 0 \text { m}^2/\text {s} \quad {\text{{ on }}} \mathrm {\Gamma }_{\text {wall}}\\ {v_r} = {0} \text { and } \frac{\partial v_{r}}{\partial r }= \frac{\partial v_{z}}{\partial r } = \frac{\partial p}{\partial r } = \frac{\partial {R_\mathrm {T}}}{\partial r } = {0} \quad \text { on } \mathrm {\Gamma }_{\text {sym}}\\ ({\varvec{T}} + {\varvec{T}}_R) {\cdot } {\varvec{n}} = {\varvec{0}}\text { and } \nabla {R_\mathrm {T}} {\cdot } {\varvec{n}} = 0 \quad {\text{{ on }}} \mathrm {\Gamma }_{\text {out}} \\ \end{array} $$
(9)
Fig. 2
figure 2

Example of boundaries for the 2D swirl flow device, for the case in which the computational domain features an interface to the symmetry axis

2.4 Weak formulation

As will be mentioned in Sect. 5, the finite element method is needed for the scheme used for the automatic derivation of the adjoint model, which means that it is necessary to define the weak formulation. The derivation of the weak form is given by considering the weighted-residual and Galerkin methods for the mixed (velocity–pressure) formulation as follows (Reddy and Gartling 2010; Alonso et al. 2018):

$$\begin{aligned} {R}_{c} = \int _{ {\Omega }}[\nabla {\cdot }{\varvec{v}}]{\textit{w}}_{p}rd {\Omega }\end{aligned}$$
(10)
$$\begin{aligned}R_m = &\int_{\Omega} [\rho\nabla {\varvec\nu}\cdot {\varvec\nu} - \rho {\varvec{f}} + \rho({\varvec\omega}\wedge {\varvec{\nu}}) \\& + \rho{\varvec\omega}\wedge ({\varvec\omega} \wedge {\varvec{r}})]\cdot{{\varvec{w}}_{\varvec{v}}}rd\Omega + \int_{\Omega} ({\varvec{T}} + {\varvec{T}}_R)\cdot({\nabla}{\varvec{w}}_v)rd\Omega \\&-\oint_\Gamma (({\varvec{T}} + {\varvec{T}}_R)\cdot{{\varvec{w}}_v}) \cdot {\varvec{n}}rd\Gamma + \int_{\Omega} \kappa(\alpha){{\varvec{v}}_{mat}}\cdot{{\varvec{w}}_v}rd\Omega \end{aligned}$$
(11)
$$\begin{aligned} R_{{\text{WA}}2018} &={\int_{\Omega}} \left[ \rho {\varvec{v}}\cdot\nabla {R_{\rm T}} \right] w_{R_{\rm T}} rd\Omega \\&+ {\int_{\Omega}} \left[ ({\sigma_R} \rho {R_{\rm T}} + \mu)\nabla {R_{\rm T}} \right] \cdot w_{R_{\rm T}} rd\Omega \\&- \oint_{\Gamma} {\varvec{n}} \cdot \left[ ({\sigma_R} \rho {R_{\rm T}} + \mu)\nabla {R_{\rm T}} \right] w_{R_{\rm T}} rd\Gamma \\&- \int_{\Omega} \rho {C_1} {R_{\rm T}} {Sw_{R_{\rm T}}}rd\Omega \\&- \int_{\Omega} {f_1} {C_{1, k- \omega}}\rho \frac{R_{\rm T}}{S} \nabla {R_{\rm T}}\cdot \nabla {Sw_{R_{\rm T}}}rd\Omega \\&+ \int_{\Omega} \rho (1-{f_1}) {\text{min}} \left[ {C_{2, k-\epsilon}} {R_{\rm T}^2} \left( \frac{\nabla S \cdot \nabla S}{S^2}\right), {C_m} {\nabla} {R_{\rm T}} \cdot {\nabla} {R_{\rm T}}\right] {w_{R_{\rm T}}} rd\Omega \\&+ \int_{\Omega} {\lambda}_{R_T} \kappa (\alpha) {R_{\rm T}} {w_{R_{\rm T}}} rd\Omega \end{aligned}$$
(12)

where the subscripts “c,” “m,” and “\(\text {WA2018}\)” refer to the “continuity” equation, the “linear momentum” (Navier–Stokes) equations, and the “Wray–Agarwal (2018)” equation, respectively. The test functions of the state variables (p, \({\varvec{v}}\) , and \(R_\text {T}\)) are given by \({\textit{w}}_{p}\), \({{\varvec{w}}}_{v}\) , and \({\textit{w}}_{R_\text {T}}\), respectively. When considering 2D swirl flow, since the integration domain (\(2\pi r d {\Omega }\)) contains a constant multiplier (\(2\pi\)), which does not pose influence when solving the weak form, Eqs. (10), (11), and (12) are given divided by \(2\pi\) (Alonso et al. 2018, 2019).

From the mutual independence of the test functions, the three equations of the weak form can be summed to a single equation:

$$\begin{aligned} F = {R}_{c} + {R}_{m} + {R}_\text {WA2018} = 0 \end{aligned}.$$
(13)

3 Formulation of the topology optimization problem

3.1 Material model

The material model is the change in the fluid flow equations that controls how the design variable (pseudo-density) influences the fluid flow simulation (\(\alpha = 0\) for solid, and \(\alpha = 1\) for fluid). In the case of fluid flow topology optimization, it serves so as to block parts of the fluid flow according to the design variable (pseudo-density), while also helping to guide the optimization process. Borrvall and Petersson (2003) suggest the following convex interpolation function for the material model for fluid flow (also known as “inverse permeability”):

$$\begin{aligned} \kappa (\alpha ) = \kappa _{\text {max}} + (\kappa _{\text {min}} - \kappa _{\text {max}})\alpha \frac{1 + q}{\alpha + q} \end{aligned},$$
(14)

where the inverse permeability (\(\kappa (\alpha )\)) is bounded by \(\kappa _{\text {max}}\) (maximum value) and \(\kappa _{\text {min}}\) (minimum value). The penalization parameter, referred as q (\(q > 0\)), controls the convexity (relaxation) of the material model. Large values of q imply a less relaxed material model.

3.2 Topology optimization problem

The topology optimization problem is formulated as follows:

$$\begin{aligned} \boxed { \begin{aligned} {\underset{{\alpha }}{\mathbf {min\ }}}\, &{{\Phi }}_{\text {rel}}(p(\alpha ),{\varvec{v}}(\alpha ), R_{\text {T}}(\alpha ),\alpha ) \\ \mathbf {such\ }\,&\mathbf { that} \\ \text {Flu}&\text {id volume constraint}{: }\int _{ {\Omega }_{\alpha }}\alpha (2\pi rd {\Omega }_{\alpha }) \leqslant \ f V_{0}\\ \text {Box}&\text { constraint of }\alpha {: }0\ \leqslant \ \alpha \leqslant \ 1 \end{aligned} } \end{aligned},$$
(15)

where f is the specified volume fraction, \(V_{0} = \int _{ {\Omega }_{\alpha }}2\pi r d {\Omega }_{\alpha }\) is the volume of the design domain (\({\Omega }_{\alpha }\)), \({ {\Phi }}_{\text {rel}}(p(\alpha ),{\varvec{v}}(\alpha ), R_{\text {T}}(\alpha ),\alpha )\) is the objective function, and \(p(\alpha )\), \({\varvec{v}}(\alpha )\) , and \(R_{\text {T}}(\alpha )\) are, respectively, the pressure, the velocity, and the undamped eddy viscosity obtained from the solution of the boundary value problem (Eq. (9)), which features an indirect dependency with respect to the design variable \(\alpha\).

3.3 Objective function

The objective function is selected as the relative energy dissipation (\({\Phi }_{\text {rel}}\)), as defined in Alonso et al. (2018), which is based on the definition of energy dissipation from Borrvall and Petersson (2003) and includes inertial effects. In this work, it also includes the turbulence effect (similarly to Yoon (2016)), defining a “total relative energy dissipation.” By considering zero external body forces,

$$\begin{aligned} \begin{aligned} {\Phi }_{\text {rel}}&= \int _{ {\Omega }}\left[ \frac{1}{2} (\mu + \mu _\text {T}) (\nabla {\varvec{v}} + {\nabla {\varvec{v}}}^{T}){\cdot }(\nabla {\varvec{v}} + {\nabla {\varvec{v}}}^{T})\right] 2\pi rd {\Omega }\\&+ \int _{ {\Omega }}{\varvec{\kappa }}(\alpha ){\varvec{v}}_{\text {mat}}{\cdot }{\varvec{v}} 2\pi rd {\Omega }\\&+ \int _{ {\Omega }} (2\rho ({\varvec{\omega }}{\wedge }{\varvec{v}}) + \rho {\varvec{\omega }}{\wedge }({\varvec{\omega }}{\wedge }{\varvec{r}})){\cdot }{\varvec{v}}2\pi rd {\Omega }\end{aligned} \end{aligned}.$$
(16)

3.4 Sensitivity analysis

The sensitivity is given by the adjoint method as

$$\begin{aligned}&\left( \frac{d{\Phi }_{\text {rel}}}{d\alpha }\right) ^{{*}} = \left( \frac{\partial {\Phi }_{\text {rel}}}{\partial \alpha }\right) ^{\text {*}} - \left( \frac{\partial F}{\partial \alpha }\right) ^{\text {*}}{{\varvec{\lambda }}}_{{\Phi }_{\text {rel}}} \end{aligned}$$
(17)
$$\begin{aligned}&\left( \frac{\partial {F}}{\partial ({\varvec{v}}, p, R_{\text {T}})}\right) ^{\text {*}}{{\varvec{\lambda }}}_{{\Phi }_{\text {rel}}} = \left( \frac{\partial {\Phi }_{\text {rel}}}{\partial ({\varvec{v}}, p, R_{\text {T}})}\right) ^{\text {*}} \text {(adjoint equation)} \end{aligned},$$
(18)

where the weak form is given by \({F} = 0\), “*” represents conjugate transpose, and \({{\varvec{\lambda }}}_{ {\Phi }_{\text {rel}}}\) is the adjoint variable (Lagrange multiplier of the weak form).

3.5 Helmholtz pseudo-density filter

The topology optimization results in this work consider the use of a Helmholtz pseudo-density filter, which is a PDE-based topology optimization pseudo-density filter (Lazarov and Sigmund 2010), for regularization. This filter is shown schematically in Fig. 3, where \(\alpha\) represents the original distribution (i.e., before applying the filter) of the design variable and \({\alpha }_{f}\) is the filtered distribution of the design variable (i.e., after applying the filter).

Fig. 3
figure 3

Schematic representation of the Helmholtz pseudo-density filter being used onto \(\alpha\)

As represented in Fig. 3, the Helmholtz pseudo-density filter is equivalent to weighting each value of the original design variable (\(\alpha\)) with a Green’s function, which is a function that is always positive and whose integral is equal to 1 (Lazarov and Sigmund 2010). If the filter length parameter (\(r_H\)) is chosen with a small value, this Green’s function approaches a Dirac’s delta function (\({\alpha }_{f} \xrightarrow []{r_H\rightarrow 0^{+}} \alpha\)). This Green’s function averaging is equivalent to the solution of a modified Helmholtz equation with homogeneous Neumann boundary conditions, whose boundary value problem is given by (Lazarov and Sigmund 2010; Zauderer 1989)

$$\begin{aligned} \begin{aligned} - r_{H}^2 \nabla ^2 {\alpha }_{f} + {\alpha }_{f}&= \alpha&\text { in } \mathrm {\Omega }\\ \frac{\partial {{\alpha }_{f}}}{\partial {{\varvec{n}}}}&= {\varvec{0}}&\text { on } \mathrm {\Gamma }\end{aligned} \end{aligned}$$
(19)

where \({\alpha }\) is the original design variable (i.e., before applying the filter), \({\alpha }_{f}\) is the filtered design variable (i.e., after applying the filter), and \(r_H\) is the filter length parameter.

The weak form is obtained by multiplying Eq. (19) by the test function \({\textit{w}}_{HF}\) and integrating in the whole design domain as follows:

$$\begin{aligned} \begin{aligned} r_{H}^2 \int _{ {\Omega }} (\nabla {\alpha }_{f}){\cdot }\nabla {\textit{w}}_{HF} r d {\Omega }+ \int _{ {\Omega }}&{\alpha }_{f} {\textit{w}}_{HF} r d {\Omega }\\&- \int _{ {\Omega }} \alpha {\textit{w}}_{HF} r d {\Omega }= 0 \end{aligned} \end{aligned}.$$
(20)

When considering a Helmholtz pseudo-density filter in topology optimization, \(\alpha\) is replaced by \({\alpha }_{f}\) in all of the fluid flow equations, including the objective function (i.e., Eqs. (10), (11), (12), and (16)), and the sensitivities include the dependency of \({\alpha }_{f}\) with respect to \(\alpha\) (from the chain rule, \(\frac{d {\Phi }_{\text {rel}}}{d \alpha } = \frac{d {\Phi }_{\text {rel}}}{d{\alpha }_{f}} \frac{d {\alpha }_{f}}{d\alpha }\)) (Lazarov and Sigmund 2010).

4 TOBS approach

The TOBS (Topology Optimization of Binary Structures) algorithm (Sivapuram and Picelli 2018; Sivapuram et al. 2018) consists of a binary variables’ formulation which is given by sequentially solving linearized integer variable problems (considering \(\alpha _{lb} = 0\) (lower bound) and \(\alpha _{ub} = 1\) (upper bound)). In order to present a generic formulation adequate to this work, the TOBS formulation is rewritten with respect to the following generic topology optimization problem:

$$\begin{aligned} \boxed { \begin{aligned}&{\underset{{\alpha }}{\mathbf {min\ }}} {J}(\alpha ) \\&\mathbf {such\ } \mathbf {that} \\&\ \ \text {Equality constraints: }c_{\text {eq},i}(\alpha ) = 0,\ i = 1,\ 2\ ...\ n_\text {eq}\\&\ \ \text {Inequality constraints: }c_{\text {ineq},i}(\alpha ) \leqslant \ 0,\ i = 1,\ 2\ \ldots\ n_\text {ineq}\\&\ \ \text {Box constraint of }\alpha {: }\alpha _{lb}\ \leqslant \ \alpha \leqslant \ \alpha _{ub} \end{aligned} } \end{aligned},$$
(21)

where \(J(\alpha )\) is the objective/multi-objective function, \(c_{\text {eq},i}(\alpha )\) is the definition of the equality constraint i, \(c_{\text {ineq},i}(\alpha )\) is the definition of the inequality constraint i, \(n_\text {eq}\) is the number of equality constraints, \(n_\text {ineq}\) is the number of inequality constraints, \(\alpha _{ub}\) is the upper bound of the design variable, and \(\alpha _{lb}\) is the lower bound of the design variable. It can be reminded that, for the optimizer, Eq. (21) consists of a multivariable optimization problem, in which the number of variables is given by the quantity of values of the design variable (\(n_\alpha\)) that are distributed over the mesh, obtained by considering the finite element modeling.

Essentially, in the TOBS approach, the optimization problem from Eq. (21) is successively solved as the following linearized formulation for the variation of the design variable (“design variable step,” \({\Delta }\alpha\)):

$$\begin{aligned} \boxed { \begin{aligned}&{\underset{{{\Delta }\alpha }}{\mathbf {min }}} \left. \frac{d{J}}{d\alpha }\right| _{\alpha = \alpha } {\Delta }\alpha \\&\mathbf {such\ } \mathbf {that} \\&\ \ \text {Inequality constraints: }\left. \frac{dc_{\text {ineq},i}}{d\alpha }\right| _{\alpha = \alpha }{\Delta }\alpha \leqslant \ {{\Delta }}c_{\text {ineq},i}(\alpha ),\\&\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ i = 1,\ 2\ ...\ (n_\text {ineq} + 2 n_\text {eq})\\&\ \ \text {Truncation error constraint: } |\!| {\Delta }\alpha |\!|_{1} \leqslant \beta _\text {flip\ limit} n_\alpha \\&\ \ \text {Allowed values of }{\Delta }\alpha \text {: }{\Delta }\alpha \in \{\alpha _{lb} - \alpha , \alpha _{ub} - \alpha \} \end{aligned} } \end{aligned},$$
(22)

where \(\alpha\) is the value of the design variable in the beginning of the iteration of the optimization, \(\left. \frac{\text{{d}}{J}}{\text{{d}}\alpha }\right| _{\alpha = \alpha }\) and \(\left. \frac{\text{{d}}c_{\text {ineq},i}}{\text{{d}}\alpha }\right| _{\alpha = \alpha }\) are the sensitivities of the objective function and the inequality constraints computed at \(\alpha\), respectively, \(\beta _\text {flip\ limit}\) is a factor that limits the “number of flips/jumps” of \(\alpha\) from one discrete value to another (0 or 1), \(n_\alpha\) is the quantity of values of the design variable (\(\alpha\)) that are distributed over the mesh, \(|\!| {\Delta }\alpha |\!|_{1}\) is the one-norm (\(\ell _1\) norm) of \({\Delta }\alpha\), and the next value of the design variable is given as \(\alpha + {\Delta }\alpha\). It can be noticed that equality constraints (\(c_{\text {eq},i}(\alpha )\)) that are computed with floating point numbers are numerically extremely hard (if not impossible) to be exactly satisfied, which may lead to linearized problems with “impossible” integer solutions. In such case, the equality constraints should be substituted in Eq. (21) by inequality constraints with a given variation around the bounds (i.e., \(c_{\text {eq},i}(\alpha ) - \delta _\text {eq, i} \leqslant 0\) and \(-(c_{\text {eq},i}(\alpha ) + \delta _\text {eq, i}) \leqslant 0\), where \(\delta _\text {eq, i}\) is a small bound for the definition of the equality constraints converted to inequality constraints). Therefore, the number of inequality constraints becomes \(n_\text {ineq} + 2 n_\text {eq}\).

The truncation error constraint is included in order to keep the truncation error of the linearization small (Sivapuram and Picelli 2018). The linearized inequality constraint bound (\({ {\Delta }}c_{\text {ineq},i}(\alpha )\)) is relaxed in order to guarantee that the integer solution of the linearized problem is feasible (Sivapuram and Picelli 2018). This relaxation essentially changes the value of \({\Delta} c_{\text {ineq},i}(\alpha )\) when \(c_{\text {ineq},i}\) is “far” (based on a reference value (\(c_{\text {ref}, i}\))). Then, the relaxation presented in Sivapuram and Picelli (2018) becomes

$$\begin{aligned} {\mathrm {\Delta }}c_{\mathrm {ineq},i}(\alpha ) = {\left\{ \begin{array}{ll} -\varepsilon _\mathrm {relax}(c_{\mathrm {ineq},i}(\alpha ) + c_{\mathrm {ref}, i}), \\ \ \ \ \text {if } c_{\mathrm {ineq},i}(\alpha ) > \frac{\varepsilon _\mathrm {relax}c_{\mathrm {ref}, i}}{1 - \varepsilon _\mathrm {relax}} \\ \ \\ -c_{\mathrm {ineq},i}(\alpha ), \\ \ \ \ \text {if } \frac{-\varepsilon _\mathrm {relax} c_{\mathrm {\mathrm {ref}}, i}}{1 + \varepsilon _\mathrm {relax}} \leqslant c_{\mathrm {ineq},i}(\alpha ) \leqslant \frac{\varepsilon _\mathrm {relax}c_{\mathrm {ref}, i}}{1 - \varepsilon _\mathrm {relax}} \\ \ \\ \varepsilon _\mathrm {relax}(c_{\mathrm {ineq},i}(\alpha ) + c_{\mathrm {ref}, i}),\\ \ \ \ \text {if } c_{\mathrm {ineq},i}(\alpha ) < \frac{-\varepsilon _\mathrm {relax}c_{\mathrm {ref}, i}}{1 + \varepsilon _\mathrm {relax}} \end{array}\right. } \end{aligned}$$
(23)

where \(0< \varepsilon _\text {relax} < 1\) is a constraint relaxation parameter, and \(c_{\text {ref}, i} \ne 0\) is a reference value for the constraint i. The reference value \(c_{\text {ref}, i}\) is a representative value for the magnitude of the values that are achievable in the constraint, in order to define the size of the linearized interval. The reference value \(c_{\text {ref}, i}\) cannot be set as 0, otherwise Eq. (23) becomes \({\Delta}c_{\text {ineq},i}(\alpha ) = -\varepsilon _\text {relax}\Big |{c_{\text {ineq},i}(\alpha )}\), meaning that the linearized interval disappeared from the formulation. Equation (23) is illustrated in Fig. 4: when \(c_{\text {ineq},i}(\alpha ) > \frac{\varepsilon _\text {relax}c_{\text {ref}, i}}{1 - \varepsilon _\text {relax}}\), the constraint bound is “softened,” widening the solution space; when \(\frac{-\varepsilon_\text{relax} c_{{\text {ref}}, i}}{1 + \varepsilon _\text {relax}}< c_{\text {ineq},i}(\alpha ) < \frac{\varepsilon _\text{relax}c_{\text {ref}, i}}{1 - \varepsilon _\text {relax}}\), the linearized value is used for the constraint bound; and when \(c_{\text {ineq},i}(\alpha ) < \frac{-\varepsilon _\text {relax}c_{\text {ref}, i}}{1 + \varepsilon _\text {relax}}\), the constraint bound is “stricter,” decreasing the solution space to enforce a feasible or near-feasible value. The red-colored vertical arrows represent the change in the solution space from the linearized constraint when considering the relaxation. The solution space is represented in dark blue color, and represents the possible values for \(\left. \frac{\text{{d}}c_{\text {ineq},i}}{\text{{d}}\alpha }\right| _{\alpha = \alpha } {\Delta }\alpha\) (from Eq. (22)).

Fig. 4
figure 4

Relaxation of the linearized inequality constraint bound (\({\Delta}c_{\text {ineq},i}(\alpha )\))

The convergence criterion can be analyzed from successive objective function values (Huang and Xie 2007) or when there are no more changes in the topology (\({\Delta }\alpha = 0\)). The solution of the TOBS linearized problem [Eq. (22)] is performed by an integer programming optimizer, such as the commercial software CPLEX® (from IBM), or the open source software CBC (from the COIN-OR project).

It can be mentioned that the numerical implementation of the TOBS algorithm includes additional normalizations (from the source code from Sivapuram and Picelli (2018)), which are \(\left. \frac{\text{{d}}{J}}{\text{{d}}\alpha }\right| _{\alpha = \alpha } {\Delta }\alpha\) is divided by \(\text {max}\left[ \left. \frac{\text{{d}}{J}}{\text{{d}}\alpha }\right| _{\alpha = \alpha }\right]\), while \(\left. \frac{\text{{d}}c_{\text {ineq},i}}{\text{{d}}\alpha }\right| _{\alpha = \alpha } {\Delta }\alpha \leqslant \ {\Delta}c_{\text {ineq},i}(\alpha )\) is divided by \(\text {max}\left[ \left. \frac{\text{{d}}c_{\text {ineq},i}}{\text{{d}}\alpha }\right| _{\alpha = \alpha }\right]\).

5 Numerical implementation of the optimization problem

The fluid flow simulation is computed in the OpenFOAM® software (version from “The OpenFOAM foundation”) (Weller et al. 1998; Chen et al. 2014), which is able to efficiently compute the turbulent fluid flow simulation. The other platform that is considered is FEniCS (Logg et al. 2012), which is a finite elements software based on automatic differentiation and relies on a high-level language for representing the weak form and functionals for later assembling the finite element matrices. Besides being more computationally efficient than FEniCS to model turbulent fluid flow (Mortensen et al. 2011), OpenFOAM® also avoids the need of including possibly counter-intuitive modifications to the finite element model just for trying to achieve the convergence of the simulation (Mortensen et al. 2011) such as intermediary projections, derivative approximations, preconditioning part of the system of equations, pseudo-transient solution, and additional value limiters. The SIMPLE (Semi-Implicit Method for Pressure-Linked Equations) algorithm (Patankar 1980; OpenFOAM 2014) is considered for the simulations. The implementation of the Wray–Agarwal model (2018) in OpenFOAM® is based on the implementation of its original authors (CFD group 2020). Thus, on the one hand, the main disadvantage of OpenFOAM® is that it does not provide an easy and efficient way to automatically derive the adjoint model. On the other hand, although FEniCS is not efficient for turbulent flow simulation, it may be used to automatically generate an efficient adjoint model with the dolfin-adjoint library (Farrell et al. 2013; Mitusch et al. 2019). For the automatic derivation of the adjoint model, the primal equations of the finite element method must be implemented in FEniCS (Sect. 2.4). The automatic differentiation from FEniCS is based on operator overloading in its high-level language (UFL). The variable values in OpenFOAM® are mapped to discrete variables in FEniCS, and then projected into the state variables in FEniCS, including a small smoothing (Alonso et al. 2021).

The solution of the TOBS linearized problem (Eq. (22)) is performed by the integer programming optimizer CPLEX®, because it is currently faster than CBC and provides an academic license.

The implementation of the topology optimization method is shown in Fig. 5. From the initial guess for the pseudo-density distribution inside the design domain, the adjoint model is “annotated” by dolfin-adjoint for the automatic derivation of the adjoint model. Then, the TOBS optimization loop is started. First, the TOBS linearization is performed (Eq. (23)), while communicating with dolfin-adjoint for computing the objective function, constraints, and sensitivities. The sensitivities are computed from the adjoint model, with the state variable values coming from the simulation performed in OpenFOAM®. Continuing the TOBS optimization loop, the integer programming optimizer (CPLEX®) is called, the topology is updated, and the convergence is verified with a specified tolerance for the change in the pseudo-density distribution (convergence criterion).

Fig. 5
figure 5

Flowchart illustrating the numerical implementation of the topology optimization problem

The sensitivities (of the objective function and constraint) are adjusted by the volume of each element, which is similar to considering the use of a Riesz map in the sensitivity analysis and has the effect of leading to mesh-independency in the computed sensitivities (Schwedes et al. 2017). The mesh-independency effect of the Riesz map is particularly interesting when considering non-uniform meshes, where the non-adjusted sensitivity distribution may be a seemingly less-smooth distribution and may hinder the topology optimization process. In the case of the 2D swirl flow model, the elements can be viewed in 3D as “ring-shaped,” which means that there is a linear non-uniformity in the mesh when comparing lower and higher radii. In the case of a nodal design variable, the adjusted sensitivity is given by

$$\begin{aligned} \begin{aligned}&\left. \frac{\text{{d}}J}{\text{{d}}\alpha }\right| _\text {adjusted} = \frac{1}{V_\text {nel}} \frac{\text{{d}}J}{\text{{d}}\alpha } \underbrace{ \left[ \frac{\sum \limits _{\text {nodes}}^{} V_\text {nel}}{n_\text {nodes}} \right] }_{\begin{array}{c} \text {Average neighbor}\\ \text {elements' volume} \end{array}} \end{aligned} \end{aligned},$$
(24)

where \(V_\text {nel}\) is the sum of the volumes of the neighbor elements that touch a node/vertex in the mesh, and \(n_\text {nodes}\) is the number of nodes/vertices in the mesh. In the 2D swirl flow model, the volumes are computed by considering axisymmetry (i.e., “ring-shaped” element volumes).

A comparison of the computed sensitivities from dolfin-adjoint with respect to finite differences can be seen in Appendix A.

5.1 Finite element modeling

For the finite elements implementation that is required for the automatic derivation of the adjoint model used in this work, it is necessary to define the finite element modeling. In order to consider a numerically stable finite elements formulation (Brezzi and Fortin 1991; Reddy and Gartling 2010; Langtangen and Logg 2016), MINI elements (Arnold et al. 1984; Logg et al. 2012) are used for coupling the discretizations of pressure and velocity (see Fig. 6). MINI elements are composed of 1st degree interpolation enriched by a 3rd degree bubble function for the velocity (P1+B3 element), and 1st degree interpolation for the pressure (P1 element). By comparing with the traditional Taylor–Hood elements (2nd degree interpolation for the velocity), the advantage of considering MINI elements is their lower computational cost (due to their lower interpolation degree). The undamped eddy viscosity (from the Wray–Agarwal model (2018)) is considered with a 1st degree interpolation (P1 element). The pseudo-density (design variable) is also considered with a 1st degree interpolation (P1 element).

Fig. 6
figure 6

Finite elements chosen for the state variables (pressure, velocity, and undamped eddy viscosity), and the design variable (pseudo-density)

6 Numerical results

In the numerical results, the fluid is water, with a dynamic viscosity (\(\mu\)) of 0.001 Pa s, and a density (\(\rho\)) of 1000.0 kg/m3.

The mesh is structured, and the elements inside it are distributed according to Fig. 7.

Fig. 7
figure 7

Distribution of triangular elements inside a rectangular partition

In order to scale the equations to increase the convergence rate of the calculation of the functionals and sensitivities in FEniCS/dolfin-adjoint, the MMGS (Millimeters–Grams–Seconds) unit system is used (i.e., the length and mass units are multiplied by a \({10^3}\) factor).

The specified tolerance for the TOBS algorithm is that the change in the pseudo-density distribution (\({\Delta }\alpha\)) is sufficiently small. In this work, the optimization is progressed until \({\Delta }\alpha = 0\).

External body forces are disregarded in the numerical examples (\(\rho {\varvec{f}} = (0,\ 0,\ 0)\)), and the specified fluid volume fraction (f) is selected as 30%. The porous medium is assumed to be under the same rotation of the reference frame (\({\varvec{v}}_{\text {mat}} = {\varvec{v}}\)), and \(\kappa _{\text {min}} = 0 \text { kg}/(\text { m}^3 \text { s})\). The initial guess for the pseudo-density (design variable) distribution is chosen differently for each numerical example. The plots of the optimized topologies are given for the values of the pseudo-density (design variable) in the center of each finite element. The letter n is used for rotation in rpm, and \(\omega\) is used for rotation in rad/s.

In the TOBS algorithm, the reference value “\(c_{\text {ref}, V}\)” (for the volume constraint) is chosen as \(f V_0\), as in previous works that consider the TOBS approach (Sivapuram and Picelli 2018; Sivapuram et al. 2018).

The pseudo-density (design variable) values in the optimized topologies are post-processed by smoothing the resulting contour (Fig. 8). All of the computed values, with the exception of the convergence curves, are computed in the post-processed meshes.

Fig. 8
figure 8

Post-processing used for the optimized topologies

For simplicity, the Reynolds number is shown as the maximum value of the local Reynolds number based on the external diameter:

$$\begin{aligned} {\text {Re}_{\text {ext,} \ell } = \frac{\mu \left| {\varvec{v}}_{\text {abs}}\right| (2 r_{{ext}})}{\rho }} \end{aligned},$$
(25)

where the absolute velocity (\({\varvec{v}}_{\text {abs}}\)) varies in each position of the computational domain, \(r_{{ext}}\) is the external radius of the computational domain (depicted as “R” in the first two numerical examples, and as “\(r_{{ext}}\)” in the last numerical example), and \(\rho\) is the density. The maximum inlet Reynolds number (considering only the inlet velocity) is also defined from eq. (25) (\(\text {Re}_{\text {in,max}}\)), but with only the velocity from the inlet profile (\({\varvec{v}}_{\text {abs},in}\)).

Since the objective of the relative energy dissipation objective function (Eq. (16)) is to indirectly maximize the pressure head (or, equivalently, minimize the head loss), the definition of the pressure head is shown as

$$\begin{aligned} \begin{aligned} H = \frac{1}{Q}&\left[ \int _{\mathrm {\Gamma }_{\text {in}} }\left( \frac{p}{\rho g} + \frac{\left| {\varvec{v}}_{\text {abs}}\right| ^{2}}{2g}\right) {\varvec{v}}{\cdot }{\varvec{n}}2\pi rd\mathrm {\Gamma }_{\text {in}} \right. \\&+ \left. \int _{\mathrm {\Gamma }_{\text {out}} }\left( \frac{p}{\rho g} + \frac{\left| {\varvec{v}}_{\text {abs}}\right| ^{2}}{2g}\right) {\varvec{v}}{\cdot }{\varvec{n}}2\pi rd\mathrm {\Gamma }_{\text {out}} \right] \end{aligned} \end{aligned}$$
(26)

where g is the gravity acceleration (9.8 m/s2).

From Eq. (26), the head loss is given as

$$\begin{aligned} \begin{aligned} H^{\prime } = -H \end{aligned} \end{aligned}.$$
(27)

The isentropic efficiency may be used for pump devices in order to characterize their efficiency (Rey Ladino 2004; Sonntag and Borgnakke 2013), being given as

$$\begin{aligned} \eta _{s} = \frac{P_{\text {ideal}}}{P_{\text {real}}} = \frac{{\Delta }h_{s}}{P_{f}/\dot{m}} = \frac{g H}{P_{f}/\dot{m}} \end{aligned},$$
(28)

where \({{\Delta }h_{s} = g H}\) is the variation of specific enthalpy (specific work) in the ideal process (Sonntag and Borgnakke 2013), \(\dot{m} = \rho Q\) is the mass flow rate, and \(P_{f}\) is the fluid power given by

$$P_{f} = \oint_{\Gamma } {\varvec{\omega} \cdot \left( {{\varvec{r}} \wedge \varvec{v}_{\text {abs}} } \right)} \rho \varvec{v}_{\text {abs}} \cdot \varvec{n}2\pi r{\text{d}}T$$
(29)

The TOBS approach is considered for \(\varepsilon _\text {relax} = 0.2\) and \(\beta _\text {flip\ limit} = 0.01\), except if explicitly written otherwise.

The inlet values for the turbulent variable (\({R_{\text {T}, in}}\)) are given from the turbulence intensity (\(I_T\)) and the turbulence length scale (\(\ell _T\)) based on the local absolute velocity on the inlet (\(\left| {{\varvec{v}}_{\text {abs}, in}}\right|\)) as

$$\begin{aligned} {R_{\text {T},in}} = \sqrt{\frac{n_{v}}{2}} I_T \ell _T \overline{\Big |{{\varvec{v}}_{\text {abs}, in}}\Big |} \end{aligned},$$
(30)

where \(\Big |{{\varvec{v}}_{\text {abs}, in}}\Big |\) is the local absolute velocity on the inlet, and \(n_{v}\) is the number of velocity components (for 2D, \(n_{v} = 2\); for 2D swirl, \(n_{v} = 3\)). In this work, \(\ell _T\) is selected as \(\ell _T = 0.07 C_{\mu }^{1/4} \ell _{\text {in}}\) (COMSOL 2018; CFD Online 2020) where \(\ell _{\text {in}}\) is the width (or diameter, in the nozzle example) of the inlet.

The inlet velocity profiles are considered to be parabolic for laminar flow, and are considered to be turbulent for turbulent flow. The turbulent velocity profiles are implemented according to De Chant (2005), which is similar to the 1/7th power law (Munson et al. 2009), in which the velocity profile is analytically deduced from a simplified fluid flow model.

In order to accelerate the execution of the optimization, the OpenFOAM® simulation for each optimization step reuses the simulation result from the immediately previous optimization step. A maximum number of SIMPLE iterations per optimization step is also considered, which is set, in this work, as 2000.

Three numerical examples are presented, for evaluating the effect of the wall rotation (rotating nozzle), evaluating the effect of the inlet rotation, and evaluating in a pump device. Additionally, Appendices B and C present a 2D double-pipe design and a 2D U-bend channel design, respectively, in order to show the Wray–Agarwal model (2018) being applied for topology optimization in 2D cases. Appendix B also considers a topology with some circles as the initial guess for topology optimization.

6.1 Rotating nozzle

The first example is the design of a rotating nozzle. A nozzle is used to control the characteristics of the fluid flow entering or leaving another fluid device. This type of design has been previously evaluated for laminar 2D swirl flow by Alonso et al. (2018). Figure 9 shows the design domain that is considered in this case. Since the nozzle is rotating, the solid material distribution is optimized for these rotating walls under the same rotation of the reference frame (\(\omega _0\)).

Fig. 9
figure 9

Design domain for the rotating nozzle

The mesh consists of 19,401 nodes and 38,400 elements (i.e., 80 radial and 120 axial rectangular partitions of crossed triangular elements, see Fig. 10). The input parameters, geometric dimensions, and material model parameters that are considered for the design are shown in Table 1. In this example, turbulent flow optimized topologies are compared against optimized topologies obtained from laminar flow: The inlet flow rate for laminar flow corresponds to a maximum inlet Reynolds number of 130, while the inlet flow rate for turbulent flow corresponds to a maximum inlet Reynolds number of \(1.3 \times 10^4\). Since the TOBS approach considers binary variables, the initial guess has to be chosen to be discrete: In this work, in order to facilitate convergence, a “conical” initial guess is considered (i.e., directly connecting the inlet (R) of the design domain (H) to the outlet (\(R_{out}\)) with a straight line—See the leftmost topologies in Fig. 13). It can be highlighted that, in any fluid topology optimization problem with TOBS, other discrete initial guesses are also possible, such as a “fully-fluid” initial guess, but with care taken in case there is some undesired vortex generation in the fluid for this initial guess, which may possibly hinder the topology optimization process. The specified fluid volume fraction (f) is set as 30%.

Fig. 10
figure 10

Mesh used in the design of the rotating nozzle

Table 1 Parameters used for the topology optimization of the rotating nozzle

A series of topology optimizations is performed for different rotations, whose results are shown in Fig. 11. The maximum local Reynolds numbers are computed as 479, 526, and 1060 (for the laminar optimized topologies); and \(5.9 \times 10^4\), \(6.5 \times 10^4\), and \(1.0 \times 10^5\) (for the turbulent optimized topologies). In Fig. 11a, it can be noticed that the presence of higher fluid flow velocities under laminar flow tends to increase an “inlet zone.” This inlet zone seems to help the fluid to make a smoother change in flow direction towards the middle of the nozzle. Fig. 11b shows the optimized topologies for turbulent flow. As can be seen, a similar effect to that of laminar flow (Fig. 11a) is observed. However, the 0 rpm optimized topology of turbulent flow features a concave transition near the inlet while the 0 rpm optimized topology of laminar flow features a more linear transition. This can be seen as a consequence of the different velocity profiles in both cases (turbulent and laminar velocity profiles), since a turbulent velocity profile features somewhat higher velocities when farther from the symmetry axis, with respect to a laminar velocity profile. It can also be noticed that the “outlet zone” of the turbulent nozzle is straighter than the laminar nozzle when under rotation, in which a “divergent shape” can be noticed. This “divergent shape” creates a small effect of reducing the fluid pressure and increasing the fluid velocity, which may help reducing the dissipated energy due to the fluid acceleration from the rotation effect. However, in the turbulent flow case, the effect of the rotating wall on the velocity seems to be more prominent, leading to a straighter outlet channel shape.

Fig. 11
figure 11

Topology optimization results for the rotating nozzle under different wall rotations, for laminar and turbulent flows

In order to show the effect of considering the optimized topologies for laminar flow operating under turbulent flow and vice-versa, additional simulations are performed and shown in Fig. 12. In Fig. 12, the “relative differences” are shown, which correspond to \(r_{x} = \frac{x_\text {other\ flow} - x_\text {flow}}{x_\text {flow}}\), where \(x_\text {flow}\) is the function being computed in the flow that generated the optimized topology, while \(x_\text {other\ flow}\) is the function being computed in the topology that was optimized for the other type of flow. Thus, a positive “relative difference” means that the optimized topology operates better at the flow it was optimized for. It can be noticed that almost all optimized function values are better at the flow that generated the optimized topology, with the exception of the head loss for 5000 rpm (Fig. 12b). This may possibly mean the induction of a local minimum, but, since the relative energy dissipation (objective function) is smaller in the flow that generated the optimized topology, this does not pose an issue for optimization, but may mean that the viscous effects become more apparent in the relative energy dissipation than in the head loss when under higher rotations in turbulent flow (turbulent viscosity).

Fig. 12
figure 12

Laminar and turbulent flow optimized topologies operating under the flow configurations of each other

The convergence curves for the laminar and turbulent rotating nozzles are shown in Fig. 13. From this figure, it can be promptly noticed that including an island to split the inflow dissipates more energy, such that it disappeared during the optimization iterations. It can also be noticed that the relative energy dissipation values for the turbulent case are lower in the first iterations. This is due to the fact that a limited number of simulation (SIMPLE) iterations is run at each optimization step in order to reduce the computational cost, and the volume constraint is not satisfied at the initial guess.

Fig. 13
figure 13

Convergence curve of the topology optimization of the rotating nozzle for laminar (50 rpm wall rotation) and turbulent flows (5000 rpm wall rotation)

The simulation results for the post-processed meshes for the optimized topologies for their respective flow regimes are shown in Fig. 14. As can be noticed in Fig. 14b, the turbulent effect (i.e., the turbulent viscosity) causes a higher radial–axial flow acceleration near the rotating wall, which is the opposite from the laminar flow case (Fig. 14a), where the radial–axial flow is mainly concentrated in the middle of the nozzle. This may explain the fact that the “outlet zone” is straighter in the turbulent flow optimized topology than in the laminar flow optimized topology.

Fig. 14
figure 14

Optimized topologies and variables for optimized rotating nozzles

6.2 Hydrocyclone-type device

The second example is of a hydrocyclone-type device. With respect to a “real” hydrocyclone device, it differs from the fact that it considers a single-phase flow (instead of a two-phase flow), which enters the fluid flow device from a single inlet under rotation (\(\omega _{\text {in}}\)), and exits it through a single outlet. This type of design has been previously evaluated for laminar 2D swirl flow by Alonso et al. (2018). Figure 15 shows the design domain that is considered in this case. Since the hydrocyclone-type device is static, the solid material distribution is optimized for these static walls (\(\omega _{0} = 0\text { rad}/\text {s}\)).

Fig. 15
figure 15

Design domain for the hydrocyclone-type device

The mesh is considered as the same from Fig. 10. The input parameters, geometric dimensions, and material model parameters that are considered for the design are shown in Table 2. The inlet flow rates correspond to maximum inlet Reynolds numbers \(4.0 \times 10^4\), \(4.5 \times 10^4\) , and \(5.8 \times 10^4\). Since the TOBS approach considers binary variables, the initial guess has to be chosen to be discrete: In this work, in order to facilitate convergence, an initial guess featuring a “straight connection between inlet and outlet” is considered. The specified fluid volume fraction (f) is set as 30%. In this case, since the reference frame is stationary, it can be reminded that the inertial effect terms from the relative energy dissipation (Eq. (16)) are zero.

Table 2 Parameters used for the topology optimization of the hydrocyclone-type device

A series of topology optimizations is performed for different inlet rotations, whose results are shown in Fig. 16. The maximum local Reynolds numbers are computed as \(4.18 \times 10^5\), \(4.42 \times 10^5\) , and \(5.24 \times 10^5\). In Fig. 16, it can be noticed that the channel slightly raises in position when under higher inlet rotations. This effect can be mostly attributed to the increased flow inertia when under higher inlet rotations, which tends to hinder the change in flow direction to the outlet. It can also be noticed that, as in the turbulent nozzles of Sect. 6.1, the downmost part of the channel is straight for less relative energy dissipation.

Fig. 16
figure 16

Topology optimization results for the hydrocyclone-type device under different inlet rotations

The convergence curve for the hydrocyclone-type device (1000 rpm inlet rotation) is shown in Fig. 17. From there, it can be noticed that the optimized channel slowly “rises” to its optimized positioning during topology optimization.

Fig. 17
figure 17

Convergence curve of the topology optimization of the hydrocyclone-type device (1000 rpm inlet rotation)

The simulation results for the post-processed mesh for the optimized topology for the hydrocyclone-type device (1000 rpm inlet rotation) are shown in Fig. 18. As can be noticed in Fig. 18, there is a flow acceleration from the inlet towards the outlet, which mostly happens when the fluid reaches the “straight” part of the channel, which is closer to the outlet. This is probably due to the sudden decrease in cross-sectional area near the middle of the channel, which changes it from a “cylinder-like” cross-section (“\(2\pi r { {\Delta }}z\)”) to a “disk-like” cross-section (“\(\pi r^2\)”).

Fig. 18
figure 18

Optimized topologies and variables for the optimized hydrocyclone-type device (1000 rpm inlet rotation)

6.3 Tesla-type pump device

A Tesla-type pump device is a fluid flow device that aims to pump fluid without the use of any blades, propelling the fluid by rotation combined with the boundary layer effect (referred, for simplicity, as “Tesla principle”). The Tesla principle has a variety of applications, such as pumps (Tesla 1913a), fans (Engin et al. 2009), compressors (Rice 1991), turbines (Tesla 1913b), VADs (Ventricular Assist Devices) (Yu 2015), and even vacuum generation (Tesla 1921). For simplicity, the term “Tesla-type pump device” is abbreviated to simply “Tesla pump” in this work. This type of design has been previously evaluated for laminar 2D swirl flow (Alonso et al. 2018). The design domain considered in this work is shown in Fig. 19.

Fig. 19
figure 19

Design domain for the Tesla pump

The mesh consists of 10,277 nodes and 20,240 elements (i.e., 110 radial and 46 axial rectangular partitions of crossed triangular elements, see Fig. 20). The input parameters, geometric dimensions, and material model parameters that are considered for the design are shown in Table 3. In this example, the maximum inlet Reynolds number is given as \(4.92 \times 10^4\). In this work, in order to facilitate convergence, a “straight disks” initial guess is considered (see Fig. 21). The specified fluid volume fraction (f) is set as 30%.

Fig. 20
figure 20

Mesh used in the design of the Tesla pump

Fig. 21
figure 21

Straight disks reference design for the Tesla pump

Table 3 Parameters used for the topology optimization of the Tesla pump

The optimized topology is shown in Fig. 22, where the maximum local Reynolds number is given as \(1.96 \times 10^6\). As can be noticed, when under a high flow rate and rotation, the optimized channel tends to attach itself to the upper surface of the design domain, which, in fact, corresponds to the least distance from the inlet to the outlet. Table 4 shows the computed values for the reference (Fig. 21) and optimized (Fig. 22) designs. As can be noticed, the computed values show that the optimized design is an improvement in relation to the reference design, with the relative energy dissipation (\({\Phi }_{\text {rel}}\)) being slightly smaller (− 0.53%), the pressure head (H) being slightly higher (+ 1.21%), and the isentropic efficiency (\(\eta _{s}\)) also being slightly higher (+ 1.57%). It can be noticed that the relative differences are not high, because, when considering a fluid flow problem that includes a high rotational effect, the rotation itself poses a high influence in all computed functions. This leads to the effect that, if the reference topology is not chosen as a “poor-performing” topology, the computed functions should be mainly guided by the rotation, meaning that the relative performance improvement from topology optimization may not be so high.

Fig. 22
figure 22

Optimized topology for the Tesla pump

Table 4 Computed values for the reference and optimized topologies for the Tesla pump device

The convergence curve is shown in Fig. 23.

Fig. 23
figure 23

Convergence curve of the topology optimization of the Tesla pump

The simulation of the optimized design is shown in Fig. 24. From it, it can be noticed that the pressure increases more at higher radii, due to the fluid pumping. From the high rotation, the Tesla principle “dampens” a “possible collision-like” behavior of the inlet flow towards the “horizontal disk-surface,” leading the fluid to accelerate towards the outlet near the walls. This behavior seems to justify the optimized design in relation to the reference (Fig. 21), due to the fact that the main difference between the two designs would be that the reference design allows an additional axial rotational acceleration which increases the relative energy dissipation. It can also be noticed that higher velocities are achieved near the walls, due to the higher rotational effect (Tesla principle). The turbulent viscosity increases when the fluid reaches the “outlet channel,” where the fluid is more intensely rotationally accelerated.

Fig. 24
figure 24

Optimized topology and variables for the optimized Tesla pump

7 Conclusions

In this work, the topology optimization method is applied to the design of turbulent 2D swirl flow devices considering the TOBS approach and the Wray–Agarwal turbulence model (“WA2018”). Therefore, one of the main aspects that have been considered in this work is the Wray–Agarwal turbulence model (“WA2018”), which reduces the number of coefficients that need to be adjusted in topology optimization and does not require the computation of the wall distance, making it easier to perform/calibrate topology optimization. Also, the smaller number of additional equations when using this model (i.e., only one instead of two, with respect to other turbulence models) makes it simpler to implement topology optimization. Another relevant aspect is the TOBS approach, which allows the use of binary variables, eliminating the problem of appearing a “gray” medium in the optimized results.

The numerical results illustrate the use of the proposed approach. In the overall, the Wray–Agarwal turbulence model (“WA2018”) and the TOBS approach are shown to be capable of performing turbulent flow topology optimization. More specifically, in terms of the numerical examples, first, turbulent flow nozzle designs are shown to perform better than laminar flow nozzle designs when operating under turbulent flow, and vice-versa. Then, the effect of the wall rotation is illustrated for the same nozzle design, showing that the “inlet zone” tends to be enlarged for higher rotations, and then, a hydrocylone-type device is considered for different inlet rotations, showing that higher inlet rotations slightly raise the “inlet channel.” To finalize, an example of a Tesla pump is considered, showing the applicability to rotation-driven flows.

As future work, it is suggested that compressible fluid flow models be considered, as well as heat transfer and flow machine design.