Upon completing this tutorial, the user will be familiar with performing an optimal shape design of a 3D geometry. The initial geometry chosen for the tutorial is a ONERA M6 fixed wing at transonic speed in inviscid fluid. The following SU2 tools will be showcased in this tutorial:
SU2_CFD - performs the direct and the adjoint flow simulations
- SU2_DOT - projects the adjoint surface sensitivities into the design space to obtain the gradient
- SU2_DEF - deforms the geometry and mesh with changes in the design variables during the shape optimization process
- shape_optimization.py - automates the entire shape design process by executing the SU2 tools and optimizer
The resources for this tutorial can be found in the TestCases/optimization_euler/steady_oneram6 directory. You will need the configuration file (inv_ONERAM6_adv.cfg) and the mesh file (mesh_ONERAM6_inv_FFD.su2), note that the mesh file contains information about the definition of the Free Form Deformation (FFD) used for the definition of 3D design variables.
The following tutorial will walk you through the steps required when performing 3D shape design using SU2, and FFD tools. It is assumed that you have already obtained and compiled SU2_CFD, SU2_DOT, and SU2_DEF. The design loop is driven by the shape_optimization.py script, and thus Python along with the NumPy and SciPy Python modules are required for this tutorial. If you have yet to complete these requirements, please see the Download and Installation pages.
This example uses a 3D fixed-wing geometry (initially the ONERA M6) at transonic speed in air (inviscid calculation). The design variables are defined using the FFD methodology, and at the end of the mesh_ONERAM6_inv_FFD.su2 file, the description of the FFD box is provided:
Note that, only the corners of the box, and the polynomial degree in each direction are provided. The tag for the FFD box can be specified as a string name. Here, we choose "WING," as we are placing the FFD box around the wing. The provided mesh file is ready for optimization, but in the case that a user is specifying their own FFD box for a problem, the SU2_DEF module should be called after defining the options above (the levels, tag, degrees, and corner points) with the DV_KIND option set to FFD_SETTING in order to compute and write the FFD_CONTROL_POINTS and FFD_SURFACE_POINTS information to the grid file. Note that this mapping for the FFD variables only needs to be computed and stored once in the mesh file before performing design. We will describe this below.
The goal of the design process is to minimize the coefficient of drag (Cd) by changing the shape of the wing, and as design variables, we will use the z-coordinate of the FFD control point position. As the shock wave is located on the upper side of the wing, only the control points on the upper side will be used as design variables.
Mesh Description and Preprocessing
It consists of a far-field boundary divided in three surfaces (XNORMAL_FACES, ZNORMAL_FACES, YNORMAL_FACES), an Euler wall divided in three surfaces (UPPER_SIDE, LOWER_SIDE, TIP) and a symmetry plane (SYMMETRY_FACE). The specific wing is the ONERA M6, and more information on this simulation can be found in the configuration file. The surface mesh can be seen in Figure (1).
Figure (1): View of the initial surface computational mesh.
Figure (2): View of the initial FFD box, control points and the surface mesh.
The mesh file that is provided for this test case already contains the FFD information. However, if you are interested in repeating this process for your own design cases, it is necessary to calculate the position of the control points and the parametric coordinates. To do so, follow these steps at a terminal command line after defining the tags, degrees, and corner points for your FFD box (we'll use the ONERA M6 as an example):
- Move to the directory containing the config file (inv_ONERAM6_adv.cfg) and the mesh file (mesh_ONERAM6_inv_FFD.su2). Make sure that the SU2 tools were compiled, installed, and that their install location was added to your path.
- Check that DV_KIND= FFD_SETTING in the configuration file.
- Execute SU2_DEF by entering "SU2_DEF inv_ONERAM6.cfg" at the command line.
- After completing the FFD mapping process, a mesh file named "mesh_out.su2" is now in the directory. Rename that file to "mesh_ONERAM6_inv_FFD.su2". Note that this new mesh file contains all the details of the FFD method.
With this preprocessing, the position of the control points and the parametric coordinates have been calculated. A representative FFD box and the control points can be seen in Figure (2).
Configuration File Options
Several of the key configuration file options for this simulation are highlighted here. We will use a similar flow problem as that feature in the previous ONERA M6 tutorials:
Note the name of the mesh file, which includes the FFD information. Tecplot will be used for the visualization.
Optimal shape design specification:
Here, we define the objective function for the optimization as drag with a lift constraint and thickness constraints along 5 sections of the wing. The DEFINITION_DV is the list of design variables. For this problem, we want to minimize the drag by changing the position of the control points of the control box. To do so, we define the set of FFD control points. Each design variable is separated by a semicolon. The first value in the parentheses is the variable type, which is 7 for control point movement. The second value is the scale of the variable (typically left as 1.0). The name between the vertical bars is the marker tag(s) where the variable deformations will be applied. The final seven values in the parentheses are the particular information about the deformation: identification of the FFD tag, the i, j, and k index of the control point, and the allowed x, y, and z movement direction of the control point. Note that other types of design variables have their own specific input format.
A continuous adjoint methodology for obtaining surface sensitivities is implemented for several equation sets within SU2. After solving the direct flow problem, the adjoint problem is also solved. The adjoint method offers an efficient approach for calculating the gradient of an objective function with respect to a large set of design variables. This leads directly to a gradient-based optimization framework. With each design iteration, the direct and adjoint solutions are used to compute the objective function and gradient, and the optimizer drives the shape changes with this information in order to minimize the objective. Two other SU2 tools are used to compute the gradient from the adjoint solution (SU2_DOT) and deform the computational mesh (SU2_DEF) during the process. To run this design case, follow these steps at a terminal command line:
- Execute the shape optimization script by entering "shape_optimization.py -f inv_ONERAM6_adv.cfg" at the command line, add "-n 6" in case you want to run the optimization in parallel (6 processors). Again, note that Python, NumPy, and SciPy are all required to run the script.
- The python script will drive the optimization process by executing flow solutions, adjoint solutions, gradient projection, and mesh deformation in order to drive the design toward an optimum. The optimization process will cease when certain tolerances set within the SciPy optimizer are met. Note that is is possible to start the optimization from a pre-converged solution (direct and adjoint problem), in that case the following change should be done in the configuration file: RESTART_SOL= YES.
- Solution files containing the flow and surface data will be written for each flow solution and adjoint solution and can be found in the DESIGNS directory that is created. The file named history_project.plt (or history_project.csv for ParaView) will contain the functional values of interest resulting from each evaluation during the optimization.
The following are representative results for this transonic shape design example with the ONERA M6 geometry as a baseline.
Figure (3): Pressure contours showing transonic shocks on the initial design.
Figure (4): Pressure contours around the final airfoil design (Reduced shocks).
Figure (5): Optimization history.