**1. Introduction**

During recent years, there is a growing demand for designing and constructing highly efficient engineering devices and systems. Flow systems are no exception and, thus, the development of optimization tools that improve their performance is of high importance. Computational Fluid Dynamics (CFD) is a highly accurate way to predict the flow behavior within the system and, coupled with an optimization method, consist a both efficient and effective design process.

The optimization of any device starts by defining the objective-function(s) measuring its performance and the design variables. The optimal values of the design variables that minimize (or maximize) the objective function(s) are sought. The minimization (or maximization) of a single objective function, can be carried out using gradient-based methods. These make use of the gradient of the objective function to update the current geometry at the end of each optimization cycle. They converge fast and their cost is exclusively determined by the cost of computing the gradients. There is a variety of methods to compute gradients (finite differences, automatic differentiation [1], complex variables method [2]), with the adjoint [3,4] being the most efficient one, since its cost is independent of the number of design variables. The adjoint method can be developed following the continuous or discrete approach, with both of them having their own advantages and disadvantages. Their main difference relies on whether the differentiation or the discretization of the flow equations comes first. In this paper, the continuous adjoint approach, programmed in the OpenFOAM environment, is used.

*Fluids* **2020**, *5*, 11

When the flow system includes two or more fluids, a multiphase flow model must be used. The way this is formulated greatly depends on the fluid properties, their interaction and their concentrations inside the mixture [5–9]. In this paper, a flow model for two miscible fluids following a Eulerian description is used. This model is suitable for the simulation of flows inside mixing devices which do not contain moving parts. These are motionless structures that blend two or more fluids traveling inside a tube trying to deliver an homogeneous mixture at the exit. They are met in various application fields such as medicine, wastewater treatment and chemistry applications. Their functionality is based on the existence of baffles inside the tubes which force the flow to recirculate enhancing, thus, the mixing process. Apart from delivering uniform flow at the outlet, mixers should have the smallest possible power losses to reduce energy consumption. Several published studies are dealing with the flow simulation in mixing devices [10,11] or with the problem of optimizing them, targeting mixture uniformity at the exit [12–14] and minimum total pressure drop within the device [15,16], though none of them uses the adjoint method, at least to the author's knowledge. In this paper, a method based on the continuous adjoint for a two-phase model is used for the optimization of a static mixing device targeting both the aforementioned objective functions. The continuous adjoint method for this two-phase model has been developed in [17] and is, herein, summarized by presenting the adjoint partial differential equations (PDEs), the adjoint boundary conditions and the gradient expression. For the optimization of the device, the two parameterizations initially presented in [17], namely a node-based and a positional angle one, are used. A significant difference is that, in this paper, the two parameterizations are combined by formulating a two-stage optimization. Over and above, a study of a shorter device is provided to examine the impact of the length on the performance of the device, in view of a forthcoming optimization in which the tube length is an extra design variable.
