© 2011 ANSYS, Inc. September 26, 2011 1 Mesh Morphing and the Adjoint Solver in ANSYS R14.0 Genong Li Chi-Yang Cheng
© 2011 ANSYS, Inc. September 26, 2011
1
Mesh Morphing and the Adjoint Solver in
ANSYS R14.0
Genong Li
Chi-Yang Cheng
© 2011 ANSYS, Inc. September 26, 2011
2
• Fluent Morphing-Optimization Feature
• The Adjoint Solver for Optimzation
• Summary
• A Morpher Demo
Outline
© 2011 ANSYS, Inc. September 26, 2011
3
FLUENT Morpher-Optimization feature
© 2011 ANSYS, Inc. September 26, 2011
4
FLUENT Morpher-Optimization feature
•Allows users to optimize product design based on shape deformation to achieve design objective
•Based on Free-Form Deformation tool coupled with various optimization methods
© 2011 ANSYS, Inc. September 26, 2011
5
Region Defined
Examples
Some Basic examples…
Optimization based morphing…
Baseline Modified
© 2011 ANSYS, Inc. September 26, 2011
6
Process • Morpher coupled with
Optimizer 1. Setup the CFD problem
2. Invoke Mesh Morpher Tool
3. Define Objective Function
4. Define deformation region and assign deformation of control points through “Optimizer”
5. Perform solution to get the optimized design
OR What if? Optimizer
Setup Case
Run
Setup Morph
Evaluate
Choose “best” design
Regions
Parameters
Deformation
Setup Case
Run
Setup Optimizer
Optimize
Optimal Solution
Morph
Optimizer
Auto
© 2011 ANSYS, Inc. September 26, 2011
7
Morpher/Optimizer vs the WB Approach
Similarity:
The design tools have the similar idea: modify the mesh, design a design-of-experiments (DOE) space and conduct multiple CFD runs to obtain the optimal design
Differences:
• FLUENT Morpher/Optimizer does everything within FLUENT solver
• FLUENT morpher: usually handles small deformation
– Mesh count and mesh connectivity do not change, grid points are moved locally according to some smoothing algorithms
– Does not preserve the shape of the original geometry
© 2011 ANSYS, Inc. September 26, 2011
8
Example – Simple Sedan
Sequential Tabs
• Define Control Region(s)
© 2011 ANSYS, Inc. September 26, 2011
9
Deformation Definition
• Define constraint(s) (if any)
• Select control points and prescribe the relative ranges of motion
© 2011 ANSYS, Inc. September 26, 2011
10
Optimizer Algorithms; Compass, Powell, Rosenbrock, Simplex, Torczon
Auto
• Optimize!
© 2011 ANSYS, Inc. September 26, 2011
11
Results
Incompressible turbulent flow
Objective Function; Minimize Drag
Baseline Design Optimized Design
• Questions?
• Please contact ANSYS Tech support for help in applying this technology
© 2011 ANSYS, Inc. September 26, 2011
12
The Adjoint Solver in Fluent
© 2011 ANSYS, Inc. September 26, 2011
13
Gradient-based versus the Adjoint Methods in Design Optimization
• In traditional gradient-based design optimization methods, the cost of finding the sensitivities of the objective function to each design variable is proportional to the number of design variables
• In contrast, the control-theory approach, called the “adjoint method,” computes the gradients (dir. and mag.) directly by solving a set of adjoint equations.* The adjoint method therefore is extremely efficient: its cost is independent of the number of design variables
• The gradients obtained from the adjoint solver are then combined with existing design optimization methods
=================================================
* The adjoint equation is derived by using the method of Lagrange multipliers in calculus in minimizing the objective function, with the CFD governing equations as the constraint equations
© 2011 ANSYS, Inc. September 26, 2011
14
Fundamentals
FLOW SOLVER
Inputs
• Boundary mesh
• Interior mesh
• Material properties
• Boundary condition 1
• Flow angle
• Inlet velocity
• …
• …
Outputs
• Field data
• Contour plots
• Vector plots
• xy-plots
• Scalar values
• Lift
• Drag
• Total pressure drop
High-level “system” view of a conventional flow solver
HOW ARE CHANGES TO KEY OUTPUTS DEPENDENT ON CHANGES TO THE INPUTS?
© 2011 ANSYS, Inc. September 26, 2011
15
Workflow
Workflow
• Solve the flow equations and post-process the results as usual.
• Pick an observation that is of engineering interest.
Lift, drag, total pressure drop?
• Set up and solve the adjoint problem for this observation
Define solution advancement controls
Set convergence criteria
Initialize
Iterate to convergence
• Post-process the adjoint solution to get
Shape sensitivity
Sensitivity to boundary condition settings
Contour & vector plots
• Modify the mesh using a mesh deformation approach
Mesh morphing
© 2011 ANSYS, Inc. September 26, 2011
16
Shape Sensitivity
Shape sensitivity: Sensitivity of the observed value with respect to (boundary) grid node locations
mesh
nnxwDrag .)(
Shape sensitivity coefficients:
Vector field defined on mesh nodes
Node displacement
Visualization of shape sensitivity
• Uses vector field visualization.
• Identifies regions of high and low
sensitivity.
• These are the places where changes
to the shape can have a big impact on
the quantity of interest.
• The guidance is specific to the
quantity of interest, and the current flow
state.
Drag sensitivity for NACA0012
© 2011 ANSYS, Inc. September 26, 2011
17
Full discrete adjoint for shape sensitivity
Frozen turbulence
Reduce total pressure drop, DP, through system
Internal flow – Simple 2D Example
DP = -232.8 Expect change 10.0
Baseline 1
Actual change 9.0 DP = -223.8 Expect change 8.9
Actual change 6.9 DP = -216.9 Expect change 7.0
2
Actual change 3.1 DP = -213.8 Total improvement of 8%
3
© 2011 ANSYS, Inc. September 26, 2011
18
180° Elbow optimization (pressure drop)
0
10
20
30
40
50
60
70
80
90
100
0 10 20 30
Dp
tot [P
a]
Run [-]
Thanks to Hauke Reese ANSYS Germany
© 2011 ANSYS, Inc. September 26, 2011
19
180° Elbow: Optimization Loop
Base configuration End design
© 2011 ANSYS, Inc. September 26, 2011
20
Goal is to reduce the total pressure drop through the system
Set up and solve the adjoint system with a total pressure drop objective function
Total Pressure Drop in a Duct
Flow residuals
Adjoint residuals
Flow
Outflow
© 2011 ANSYS, Inc. September 26, 2011
21
Aggressive adjustment results in a 17% reduction in loss in just one design iteration
Total Pressure Drop in a Duct Total Pressure Drop (Pa)
Geometry Predicted Result
Original --- -22.0
Modified -14.8 -18.3
© 2011 ANSYS, Inc. September 26, 2011
22
Summary
• FLUENT continues to offer enhancements and improvements in efficiency and accuracy in the core solver
• FLUENT offers a number of practical and high-end design/optimization tools to accelerate the use of FLUENT as a design tool
© 2011 ANSYS, Inc. September 26, 2011
23
Demo Problem
Inlet
Exit 1
Exit 2
The goal is to modify the shape of the straight duct section so that flow rates from two exits are the same
© 2011 ANSYS, Inc. September 26, 2011
24
© 2011 ANSYS, Inc. September 26, 2011
25
Examples
© 2011 ANSYS, Inc. September 26, 2011
26
Full discrete adjoint for shape sensitivity
Frozen turbulence
Reduce total pressure drop, DP, through system
Total Pressure Drop in a Bend
DP = -232.8 Expect change 10.0
Baseline 1
Actual change 9.0 DP = -223.8 Expect change 8.9
Actual change 6.9 DP = -216.9 Expect change 7.0
2
Actual change 3.1 DP = -213.8 Total improvement of 8%
3
© 2011 ANSYS, Inc. September 26, 2011
27
The adjoint solver will be released with R14
An adjoint solver computes sensitivity data that can be used to aid with design decisions in 4 main ways:
1. Qualitative identification of critical parts of the system of interest.
2. Quantitative predictions of the optimal choice for a design change and a prediction of the effect of that change.
3. Aiding in the numerical analysis of the flow solution to improve solution quality.
4. Gradient-based optimization.
Supporting technologies such as mesh morphing, and the application of design constraints, are seen as important.
The adjoint solver for the present release is limited to steady incompressible flows, with other restrictions on models.
Summary
© 2011 ANSYS, Inc. September 26, 2011
28
Objective Function
Baseline Design Optimized Design
• Objective Function: Equal flow rate
© 2011 ANSYS, Inc. September 26, 2011
29
Mesh Morphing
Applies a geometric design change directly to the mesh in the solver
Uses a Bernstein polynomial-based morphing scheme
• Freeform mesh deformation defined on a matrix of control points leads to a smooth deformation
• Works on all mesh types (Tet/Prism, CutCell, HexaCore, Polyhedral)
User prescribes the scale and direction of deformations to control points distributed evenly through the rectilinear region.
© 2011 ANSYS, Inc. September 26, 2011
30
RBF-Morph
© 2011 ANSYS, Inc. September 26, 2011
31
RBF-Morph
© 2011 ANSYS, Inc. September 26, 2011
32
How RBF-Morph Works? • Once displacements are defined by the user at the source points, Radial Basis Function interpolation is used to derive the displacement at any location in the space, so it is also available at every grid node. • The RBF problem definition is mesh independent, same set up can be applied to different meshes
© 2011 ANSYS, Inc. September 26, 2011
33
External flow example
© 2011 ANSYS, Inc. September 26, 2011
34
RBF-Morph main features
• Fully integrated within FLUENT and Workbench
• Easy to use
• Parallel calculation allows to morph large size models (many millions of cells) in a short time
• Mesh independent solution works with all element types (tetrahedral, hexahedral, polyhedral, etc.)
• Superposition of multiple RBF-solutions makes the FLUENT case truly parametric (only 1 mesh is stored)
– RBF-solution can also be applied on the CAD
• Precision: exact nodal movement and exact feature preservation.
© 2011 ANSYS, Inc. September 26, 2011
35
Ship hull: Series 60, CB=0.6
external hydrodynamics
multiphase flow (air & water)
ship advancing steadly in calm water
trim and sinkage fixed
displaced volume as constraint
resistance prediction
Objective: Optimization of the hull shape with no displacement reduction
Reduction of the resistance
Test case description
Conducted by Pranzitelli & Caridi
© 2011 ANSYS, Inc. September 26, 2011
36
CAD
Mesh ICEM-CFD
Baseline sim. Fluent
Workbench and RBF-morph setup
DOE RUNS
Optimization
Final solution
op
era
tor
wo
rkb
ench
Process
grid cells
Coarse 331,652
Medium 692,984
Fine 1,274,742 CT
ΔCT
Coarse 5.81x10-3 -2.52%
Medium 5.94x10-3 -0.34%
Fine 5.96x10-3 0%
Exp.* 5.96x10-3 -
© 2011 ANSYS, Inc. September 26, 2011
37
CAD
Mesh ICEM-CFD
Baseline sim. Fluent
Workbench and RBF-morph setup
DOE RUNS
Optimization
Final solution
op
era
tor
wo
rkb
ench
Process
Symmetry plane fixed
Morphing domain defined Eight cross sections specified
Section deformation applied
© 2011 ANSYS, Inc. September 26, 2011
38
CAD
Mesh ICEM-CFD
Baseline sim. Fluent
Workbench and RBF-morph setup
DOE RUNS
Optimization
Final solution
op
era
tor
wo
rkb
ench
Process
DX builds a DOE and drives Fluent and RBF Morph
Parameters are defined and transferred to the parameter set bar for use with ANSYS DesignXplorer
© 2011 ANSYS, Inc. September 26, 2011
39
• Design of Experiments
• 45 Design Points
• Solved in Batch
• Input parameters
• Output parameters
• DOE Settings
ANSYS DesignXplorer • Results
• Sensitivity analysis
• Response Surface
© 2011 ANSYS, Inc. September 26, 2011
40
baseline
optimized
baseline
optimized
• Optimize
Optimize with ANSYS DesignXplorer
Baseline Optimized
Fx 6.83N 6.29N
• 7.9% resistance reduction
• No volume reduction
© 2011 ANSYS, Inc. September 26, 2011
41 *one Intel® i7 quad-core processor, 2.8GHz
Performance with RBF-Morph in Workbench: • Mesh generation: 6 man-hours • Fluent case setup: 1 man-hours • Baseline simulation (coarse grid): 4 CPU*-hours • Workbench and RBF-Morph setup:1 man-hours • DOE (45 simulations): 45 CPU*-hours • Optimization: Minutes
8 man hrs
2 CPU days
Without Workbench & RBF-Morph....? • Mesh generation (first mesh): 6 man-hours • Geometry (CAD) and mesh modification for each case (considering mesh automation in ICEM-CFD): 1x45 = 45 man-hours • Cases management (Fluent): 1x46 = 46 man-hours • Cases execution: 4+45 = 49 CPU*-hours • use of other optimization tools: ??
~100 man hrs
2 CPU days (optimistically)
© 2011 ANSYS, Inc. September 26, 2011
42
Preface
• The release of the adjoint solver in ANSYS Fluent 14 is the culmination of several years of R&D effort.
• This project was risky, but the rewards are great for ANSYS clients.
• There were a number of false starts and dead-ends.
• Writing an adjoint solver that meets the needs of the engineering community is not a trivial task.
• We are pleased to have come so far, and look forward to going much further.
© 2011 ANSYS, Inc. September 26, 2011
43
An adjoint solver allows specific information about a fluid system to be computed that is very difficult to gather otherwise.
The adjoint solution itself is a set of derivatives.
• They are not particularly useful in their raw form and must be post-processed appropriately.
• The derivative of an engineering quantity with respect to all of the inputs for the system can be computed in a single calculation.
– Example: Sensitivity of the drag on an airfoil to its shape.
There are 4 main ways in which these derivatives can be used:
1. Qualitative guidance on what can influence the performance of a system strongly.
2. Quantitative guidance on the anticipated effect of specific design changes.
3. Guidance on important factors in solver numerics.
4. Gradient-based design optimization.
What is an adjoint solution and how do we use those results?
© 2011 ANSYS, Inc. September 26, 2011
44
GOAL: Identify features of a system design that are most influential in the performance of the system.
EXAMPLE: – Sensitivity of the Drag on a NACA 0012 airfoil to changes in the
shape of the airfoil.
– The shape sensitivity field is extracted from the adjoint solution in a post-processing step.
How to use the results - Qualitative
High sensitivity – changes to shape have a big effect on drag
Low sensitivity – changes to shape have a small effect on drag
© 2011 ANSYS, Inc. September 26, 2011
45
GOAL: Identify specific system design changes that benefit the performance and quantify the improvement in performance that is anticipated.
EXAMPLE: – Design modifications to turning vanes in a 90 degree elbow to
reduce the total pressure drop.
– The optimal adjustment that is made to the shape is defined by the shape sensitivity field (steepest descent algorithm).
– Effect of each change can be computed in advance based on linear extrapolation.
How to use the results - Quantitative
Original DP = -232.8 Pa Expected change computed using the adjoint and linear extrapolation = 10.0 Pa Make the change and recompute the solution. Actual change = 9.0 Pa
Baseline Modified
© 2011 ANSYS, Inc. September 26, 2011
46
GOAL: Identify aspects of the solver numerics and computational mesh that have a strong influence on quantities that are being computed that are of engineering interest.
EXAMPLE: – Use the adjoint solution to identify parts of the mesh where mesh
adaption will benefit the computed drag by reducing the influence of discretization errors.
How to use the results – Solver Numerics
Baseline Mesh Adapted Mesh
Adapted Mesh Detail
© 2011 ANSYS, Inc. September 26, 2011
47
GOAL: Perform a sequence of automated design modifications to improve a specific performance measure for a system
EXAMPLE: – Gradient-based optimization of the total pressure drop in a pipe.
– Flow solution is recomputed and the adjoint recomputed at each design iteration.
How to use the results – Optimization
0
10
20
30
40
50
60
70
80
90
100
0 10 20 30D
pto
t [P
a]
Iteration
Initial design
Final design
30% reduction in total pressure drop after 30 design iterations
© 2011 ANSYS, Inc. September 26, 2011
48
Standard CFD Workflow elements
– Define a flow problem.
– Create a geometric representation of the problem and create a computational mesh.
– Setup and solve the flow problem.
– Post-process the results.
If the design is not meeting performance requirements
– Use insight, experience and intuition to decide how to select design changes that will improve the performance of the system
or
Adjoint workflow elements
– Use the results to improve the design systematically using one of the 4 strategies outlined
– Pick an observation that is of engineering interest.
• Lift, drag, total pressure drop?
– Set up and solve the adjoint problem for this observation for the specific computed flow field
• Define adjoint solution advancement controls
• Set adjoint convergence criteria
• Initialize the adjoint solution field
• Iterate to convergence
• Post process
How does an adjoint analysis fit into the familiar CFD workflow?
© 2011 ANSYS, Inc. September 26, 2011
49
– Mesh morphing
– Mesh morphing & Adjoint Data
– Mesh Morphing, Adjoint Data & Constraints
Supporting Technologies
© 2011 ANSYS, Inc. September 26, 2011
50
Once a desired change to the geometry of the system has been selected, how is that change to be made?
• Mesh morphing provides a convenient and powerful means of changing the geometry and the computational mesh.
– Use Bernstein polynomial-based morphing scheme discussed earlier
Mesh Morphing
© 2011 ANSYS, Inc. September 26, 2011
51
• Example: Sensitivity of lift to surface shape
• Select portions of the geometry to be modified
• Adjoint to deformation operation
• Surface shape sensitivity becomes control point sensitivity (chain rule for differentiation)
• Benefit of this approach is two-fold
• Smooths the surface sensitivity field
• Provides a smooth interior and boundary mesh deformation
Mesh Morphing & Adjoint Data
Flow
© 2011 ANSYS, Inc. September 26, 2011
52
The adjoint solution is determined based on the specific flow physics of the problem in hand.
The effect of other practical engineering constraints must be reconciled with the adjoint data to decide on an allowable design change.
Example:
– Some walls within the control volume may be constrained not to move.
– A minimal adjustment is made to the control-point sensitivity field so that deformation of the fixed walls is eliminated.
Mesh Morphing, Adjoint Data & Constraints
Fixed wall
Fixed wall
Moveable walls
© 2011 ANSYS, Inc. September 26, 2011
53
Current Functionality
ANSYS-Fluent flow solver has very broad scope
Adjoint is configured to compute solutions based on some assumptions
– Steady, incompressible, laminar flow.
– Steady, incompressible, turbulent flow with standard wall functions.
– First-order discretization in space.
– Frozen turbulence.
The primary flow solution does NOT need to be run with these restrictions
– Strong evidence that these assumptions do not undermine the utility of the adjoint solution data for engineering purposes.
Fully parallelized
Gradient algorithm for shape modification
– Mesh morphing using control points.
Adjoint-based solution adaption
© 2011 ANSYS, Inc. September 26, 2011
54
The adjoint solver is an addon that will be part of the Fluent 14 distribution.
Documentation is available
– Theory
– Usage
– Tutorial
– Case study
Training is available.
Functionality is activated by loading the adjoint solver addon module.
A new menu item is added at the top level.
Limitations include unsupported models (porous media, MRF etc.), convergence can be challenging for large cases (5-10M+ cells) and cases that exhibit unsteady flow or strong shear flows
– Stabilized solution advancement algorithm is in place
Current Functionality
© 2011 ANSYS, Inc. September 26, 2011
55
GUI
• Follow as closely as possible the same design layout as Fluent solver – Specify observable
– Adjoint solution advancement controls
– Residual monitors
– Initialization and iteration
– Post-processing: contours, vectors.
– Results reporting
– Mesh-morphing with pre-calculation of expected change in observable.
TUI
User-Interface
/adjoint>
controls morphing/ reporting/
monitors/ observable/ run/