As discussed in the previous section, a discrete adjoint approach to solving the adjoint problem has been adopted, since it is believed to provide the most useful engineering sensitivity data for the classes of problems of interest to ANSYS clients.
An adjoint method can be used to compute the derivative of an observation of interest for the fluid system with respect to all the user-specified parameters, with any changes that arise in the flow variables themselves eliminated. There are three key ingredients to consider when developing the method:
All of the user-specified inputs:
All values set by a user in the boundary condition panels for each boundary in the problem.
The computational mesh. More specifically the locations of the nodes of the mesh and how they define the edges, faces, and ultimately the cells used in the finite-volume computation. This includes both interior as well as boundary nodes.
Material properties.
Model parameters such as model coefficients for turbulence models.
Note that the settings that define the problem are being distinguished from settings that
define how the solution advancement is to be performed to converge the problem. Only the
former are of interest here. For the sake of clarity, let us denote the vector of all of the
values in the list by . These are considered to be the control variables for the problem, that is,
the variables that a user can set explicitly that affect the solution.
It is worth noting that the topological definition of the mesh is fixed—it is not considered to be a control variable here. The effect of collapsing cells or remeshing on the flow solution is not addressable without further development in view of the discrete changes that are implied. This topic is beyond the scope of the current document.
The governing equations for the fluid system:
The main effort in a flow computation is in the determination of the flow state, namely
the velocity, pressure, density and possibly other fluid-related variables. For a
cell-centered finite-volume scheme, the flow state is defined at the cell centroids by a
vector of real values. In the simplest case these values are the pressure and flow velocity
components. Let the vector of the variables in the
th cell be denoted here by
.
At convergence the flow variables satisfy
(35–25) |
where is the number of cells in the problem, and there are
conditions on each cell. This expression is a compact way of denoting
conservation of mass and momentum and other constraints.
The engineering observation of interest:
Let
(35–26) |
denote a scalar of interest that depends both on the flow state and perhaps directly on the control variables. It is assumed that the observable is differentiable with respect to both the flow and the controls. The inclusion of the control variables here is essential since in many cases the mesh geometry is included directly in the evaluation of the observable. For example, the evaluation of the force on a boundary involves the wall normal and face areas, which change when mesh nodes are moved.
The goal is to determine the sensitivity of the observation with respect to the user-specified control variables. What makes defining this relationship more challenging is the fact that changing the user inputs changes the flow, which indirectly changes the engineering observation. The adjoint method has a specific role in managing this chain of influences by providing a mechanism for eliminating the specific changes that happen in the flow whenever the inputs change.
If a variation is introduced into the control variables then a linearization of the governing
equations (Equation 35–25) shows that the variations in the flow state
must satisfy
(35–27) |
where there is an implied summation over and
, and
denotes that the flow solution is held constant while the derivative is
taken.
Meanwhile, if both the control variables and the flow state change, then the observation will change:
(35–28) |
The particular way in which the flow responds to the changes in the control variables can
be computed using (Equation 35–27) only after specific changes,
, have been chosen. It is prohibitive to consider solving (Equation 35–27) for more than a handful of prescribed changes
because of the excessive computing time that would be needed. However, when
redesigning the shape of parts of a system there may be pressure to explore a large number of
candidate modifications. This conflict is reconciled by eliminating the variations of the flow
solution from the expression (Equation 35–28) and producing an explicit
relationship between changes in the control variables and the observation of interest.
This is accomplished by taking a weighted linear combination of the linearized governing
equations (Equation 35–27) in a very particular way. A set of adjoint
variables is introduced with a one-to-one correspondence with the governing equations
(Equation 35–25). This results in a relationship
(35–29) |
The term in square brackets on the left is now matched to the coefficient for the variation in the flow in (Equation 35–28) in order to define values for the adjoint variables:
(35–30) |
These are the discrete adjoint equations, and the solution of this system that is the primary goal for the adjoint solver. It is important to recognize that these equations have not been derived. They are defined in this way with a specific goal in mind—the elimination from (Equation 35–28) of the perturbations to the flow field as shown below:
(35–31) |
Note the use of Equation 35–29 and Equation 35–30 in the derivation of Equation 35–31. The flow perturbation has now been eliminated from the expression, yielding a direct relation between the control variables and the observable of interest.
There are several important observations to be made about (Equation 35–30):
The dimension of the problem to be solved is the same as the original flow problem, although the adjoint problem is linear.
While the adjoint solution may be considered strictly as a vector of numeric values, experience with the continuous adjoint provides guidance on how the adjoint solution can be interpreted. The vector of weights associated with the components of the residual of the momentum equation in each cell is termed the adjoint velocity. The adjoint value associated with the residual of the continuity equation is termed the adjoint pressure.
The right hand side is defined purely on the basis of the observable that is of interest.
The matrix on the left hand side is the transpose of the Jacobian of the governing system of equations (Equation 35–25). This seemingly innocent transposition has a very dramatic impact on how the adjoint system is solved. This will be discussed below.
The adjoint equations are defined by the current state of the flow, and the specific physics that is employed in the modeling. Each adjoint solution is specific to the flow state.
At first glance it appears that solving the adjoint problem may be straightforward. After all it simply involves setting-up and solving a linear (albeit large) system of equations. In practice both steps can represent a significant challenge, especially when the problem is large.
The evaluation of the residuals of the flow equations is an integral part of the
pre-existing ANSYS Fluent flow solvers. However, it is necessary to compute the Jacobian of the
system and then transpose it, or at the very least to be able to make a matrix-free
transpose matrix-vector product with the adjoint solution. There are several technical
approaches to accomplishing this task whose description goes beyond the scope of this document.
Suffice to say that it is not trivial to encode this functionality, but that it has been done
successfully here.
For the present implementation, a pre-conditioned iterative scheme, based on pseudo-time marching, is adopted to solve the adjoint system. The equations that define the advancement process can be written as
(35–32) |
where is a local time step size based on the local flow conditions,
is a user-specified CFL number. The matrix
is a simplified form of the system Jacobian that is amenable to solution using
the AMG linear solver that is the workhorse of the conventional flow solver. The preconditioning
matrix
is a diagonal matrix. Artificial compressibility is introduced on the adjoint
continuity equation to aid in the relaxation of the adjoint pressure field.
The correction is under-relaxed and added to the adjoint solution
and the process repeated until the right hand side is adequately small.