Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open...

54
Continuous and Discrete adjoint methodologies within ESI CFD solvers Copyright © ESI Group, 2012. All rights reserved. Copyright © ESI Group, 2012. All rights reserved. methodologies within ESI CFD solvers Guillaume Pierrot ESI Group 1

Transcript of Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open...

Page 1: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Continuous and Discrete adjoint methodologies within ESI CFD solvers

Copyright © ESI Group, 2012. All rights reserved.Copyright © ESI Group, 2012. All rights reserved.

methodologies within ESI CFD solvers

Guillaume Pierrot

ESI Group

1

Page 2: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Rationale

Continuous Adjoint Solver within PAM-FLOW

Agenda

Copyright © ESI Group, 2012. All rights reserved.

Continuous Adjoint Solver within PAM-FLOW

Discrete Adjoint solver interfaced with CFD-ACE+

Morphing

Page 3: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Different problematics:

Rationale

global optimization

Copyright © ESI Group, 2012. All rights reserved.

0.041.05

- 17 %

local improvement

- 2500%

V

Page 4: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

One would like to improve the performance of some given design wrt some criterion: the “cost function”

may be lift, drag..

design parameters may be nodes coordinates, CAD parameters, level set position..

Rationale

Copyright © ESI Group, 2012. All rights reserved.

position..

Standard numerical simulation provides a way to evaluate a design “a posteriori”

Optimal design tools automatically select the best (or at least a better) design wrt some given criterion

Page 5: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Different optimization methods:

non-gradient based (e.g. genetic algorithms): slow but may succed in finding a global optimum

gradient-based: quicker but stop as soon as a local optimum is found

Rationale

Copyright © ESI Group, 2012. All rights reserved.

Page 6: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Different approaches for computing the gradient:

by Finite Differences PAM-OPT

by using the adjoint state PAM-FLOW Adjoint Solver, i-adjoint

Rationale

Copyright © ESI Group, 2012. All rights reserved.

by using the adjoint state PAM-FLOW Adjoint Solver, i-adjoint

Both have their pro and cons

Page 7: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

By Finite Differences:

Flexible, black box tool: very generic, no knowledge on the underlying application solver is needed

But requires a number of runs proportional to the number of design parameters

Rationale

Copyright © ESI Group, 2012. All rights reserved.

parameters

Not sustainable when it tends to be large (e.g. free shape optimization)

In pratic, used together with a surrogate model (for CPU savings), which introduces further approximation and complexity

−−−≈∇

+++

n

nnnIIIIII

Iδβδβδβ

βδβββδβββδβββ ..,,,

21

222111

CFD run 1 CFD run 2 CFD run n

Page 8: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

By using the adjoint state:

Less generic: does require some knowledge of the underlying application

Rationale

Copyright © ESI Group, 2012. All rights reserved.

Less generic: does require some knowledge of the underlying application code

More complicated requires a dedicated tool, the so-called « adjoint solver »

But requires only one primal+one adjoint run cost is independant on the number of design parameters

Well suited for shape optimization

Page 9: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

2 different approaches for computing the adjoint state:

Linearize/Dualize then Discretize Continuous Adjoint Method

Rationale

Copyright © ESI Group, 2012. All rights reserved.

Linearize/Dualize then Discretize Continuous Adjoint Method

Discretize then Linearize/Dualize Discrete Adjoint Method

Page 10: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

ESI adjoint solutions:

Continuous adjoint solver embedded into PAM-FLOW (vertex-centered FV)

Rationale

Copyright © ESI Group, 2012. All rights reserved.

Continuous adjoint solver embedded into PAM-FLOW (vertex-centered FV) (2006)

Discrete adjoint library interfaced with CFD-ACE+ (cell-centered FV,multiphysics) (2012)

Page 11: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Incompressible Navier-Stokes:

( ) =∂+∇−⋅∇ pvvv 0η αα

Continous adjoint solver

symmetrysymmetry

inle

tin

let

groundground

ou

tlet

ou

tletwallwall

Copyright © ESI Group, 2012. All rights reserved.

( )

( )

Γ==⋅∂=⋅

Γ=∂−

ΓΓ=

Γ=

=⋅∇

=∂+∇−⋅∇

symn

outn

groundwall

in

tvnv

Fvnp

v

Vv

v

pvvv

on 2100

on

on 0

on

0

0

,,; α

η

η

α

ααα

U

mass & momentum mass & momentum

conservationconservation

boundary conditionsboundary conditions

Page 12: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Optimization set-up:

( ) ( ) ∫∫

Continous adjoint solver

volumicvolumic cost cost

functionfunction

surfacic cost surfacic cost

functionfunction

Copyright © ESI Group, 2012. All rights reserved.

( ) ( )

+

∂−=∂=

+=Ω ∫∫Ω∂Ω

bcs equations S-N

and with

..

,,,,),,,,(!

ts

vpvS

nnviSpvjSpvI

αβαβ

αβ

αβ

αβ

αβαβ

ααβ

ααβ

αβ

α

ηδτ

ττ

Page 13: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

KKT theory:

( )

( ) ( ) ( )

=Ω αβ

αβ

ααβ

αβ

α τ dcbbbbqwSpvn

D

t

NDNl ,,,,,,,,,,,,

Continous adjoint solver

flow eqsflow eqs

bcsbcs

constitutive constitutive

relationsrelations

Copyright © ESI Group, 2012. All rights reserved.

( ) ( ) ( )

( ) ( )

( ) ( ) ( )

( )∫

∫∫∫

∫∫∫

Ω

ΩΓΓ

ΓΓ∪ΓΓΩ

Ω

∂−+

∂−−+⋅+⋅−

+−+⋅−+⋅∇−

+⋅∇+Ω

αβ

αβ

αβ

αβ

αβαβ

αβ

αα

αα

α

β

αβ

αααβ

αβ

α

ηδττ

δτ

ττ

dvS

cvpbnvbtn

bVvbnFvq

wvvqwSpvI

symsym

groundwallinout

N

D

t

N

DinN

U

,,,,,,

Page 14: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

KKT theory:

( )( ) 0=

Ω∂αβ

αβ

α

αβ

αβ

ααβ

αβ

α τ

dcbbbbqw

dcbbbbwqSpvn

D

t

NND

n

D

t

NND

,,,,,,,

,,,,,,,,,,,,lFlow equations + BCsFlow equations + BCs

Continous adjoint solver

Copyright © ESI Group, 2012. All rights reserved.

( )ββDNND

Adjoint equations + BCsAdjoint equations + BCs

Shape derivative (0 at Shape derivative (0 at

optimum)optimum)

( )( ) 0=

Ω∂αβ

αβ

α

αβ

αβ

ααβ

αβ

α

τ

τ

,,,

,,,,,,,,,,,,

Spv

dcbbbbwqSpvn

D

t

NNDl

( )Ω∂

Ω∂ αβ

αβ

ααβ

αβ

α τ dcbbbbwqSpvn

D

t

NND ,,,,,,,,,,,,l

Page 15: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Adjoint equations:

Continous adjoint solver

( ) ∂

∂=∇+∇⋅∇−∇⋅−∂−jj

pvvvvvααββ η

Copyright © ESI Group, 2012. All rights reserved.

( )

∂=⋅∇

∂−

∂∂=∇+∇⋅∇−∇⋅−∂−

∗∗∗

p

jv

v

j

S

jpvvvvv

ααβ

βααβ

αβ η *

cost function dependant cost function dependant

source termssource terms

Page 16: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Adjoint bcs:

Continous adjoint solver

( )

ΓΓΓ⋅∂

∂−=∗ groundwallin

n

iv on

τ αUU

cost function dependant cost function dependant

source termssource terms

Copyright © ESI Group, 2012. All rights reserved.

( )

( ) ( )

( ) ( )

Γ=⋅

∂−⋅

∂−=⋅∂⋅

⋅∂

∂−=⋅

Γ

∂+

∂+⋅+⋅=∂−

ΓΓΓ⋅∂

−=

∗∗

∗∗∗∗

sym

α

β

α

β

n

out

α

β

α

β

n

groundwallin

tnS

jt

v

itvn

n

inv

nS

j

v

ivnvnvvvnp

nv

on 21

on

on

,,; αητ

η

τ

ααα

α

αUU

Page 17: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Shape derivative:

Continous adjoint solver

( ) ( )∫Γ

∗ ⋅

∂+∇⋅∇−

Ω∂

∂=

Ω∂

wall

nS

jSvv

Iϕη

αβ

αβ

ααl

Copyright © ESI Group, 2012. All rights reserved.

keep the flow / change the shapekeep the flow / change the shape keep the shape / change the flowkeep the shape / change the flow

Page 18: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Application to Aero Force:

Continous adjoint solver

( ) ( ) ( )∫∫ΓΓ

⋅⋅=⋅∂−⋅=

wallwall

dndvdnpI n βατη

( ) =∇+∇⋅∇−∇⋅−∂− ∗∗∗ 0pvvvvv *

ααβα

β η

cost functioncost function

Copyright © ESI Group, 2012. All rights reserved.

( )

=⋅∇

=∇+∇⋅∇−∇⋅−∂−

∗∗∗

0

0

v

pvvvvv *α η

( ) ( )∫Γ

∗ ⋅∇⋅∇−=Ω∂

wall

nvv ϕη ααladjoint systemadjoint system

adjoint bcsadjoint bcs

shape derivativeshape derivative

source termsource term

( ) ( )

( )

Γ==⋅∂=⋅

Γ⋅+⋅=∂−

ΓΓ=

Γ−=

∗∗

∗∗∗∗

symn

outn

groundin

wall

tvnv

vnvnvvvnp

v

dv

on 2100

on

on 0

on

,,; αη

ηα

U

Page 19: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Pressure Drop:

Continous adjoint solver

( ) ( ) ( ) ( )∫∫∫ΓΓΓΩ

⋅⋅+⋅−=∂−⋅+−=∇+=

walloutin

vnnvvvnvvpvI n βαα τηη 22 2222

U

( ) =∇+∇⋅∇−∇⋅−∂− ∗∗∗ 0pvvvvv *

ααβα

β η

cost functioncost function

Copyright © ESI Group, 2012. All rights reserved.

( )

=⋅∇

=∇+∇⋅∇−∇⋅−∂−

∗∗∗

0

0

v

pvvvvv *α η

( ) ( )∫Γ

∗ ⋅∇⋅∇−=Ω∂

wall

nvv ϕη ααladjoint systemadjoint system

adjoint bcsadjoint bcs

shape derivativeshape derivative

( ) ( )

( ) ( )

Γ−

⋅−−

⋅+⋅=∂−

Γ−=

Γ=

∗∗∗∗

out

n

in

wall

F

nvvn v

vnvnvvvnp

Vv

v

on

2

on

on 0

2

η

source termssource terms

Page 20: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Some complication: turbulent viscosity

Continous adjoint solver

( )

=

+=αβη

ηηη

Sgt

t

Smagorinsky modelSmagorinsky model

new variablesnew variables

Copyright © ESI Group, 2012. All rights reserved.

KKT: ( )

( )

( ) ∫Ω

−+

Ω

µη

τ

µητ

αβ

αβ

αβ

ααβ

αβ

α

αβ

αβ

ααβ

αβ

α

t

n

D

t

NDN

t

n

D

t

NDN

Sg

dcbbbbqwSpv

dcbbbbqwSpv

0 ,,,,,,,,,,,,

,,,,,,,,,,,,,,

l

l

standard lagrangianstandard lagrangian

turbulent turbulent

lagrangianlagrangian

new variablesnew variables

Page 21: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Modified adjoint equations:

Continous adjoint solver

( ) ∂

∂=

∂−∇+∇⋅∇−∇⋅−∂−jjg

pvvvvv ηη ααββ

Copyright © ESI Group, 2012. All rights reserved.

( )

∂=⋅∇

∂+∇∇=

∂−

∂∂=

∂∂−∇+∇⋅∇−∇⋅−∂−

∗∗

∗∗∗∗

p

jv

jvv

v

j

S

j

S

gpvvvvv

tηη

ηη

αα

ααβ

βαβ

βααβ

αβ

*

new termnew term

volumetric cost function is allowed to volumetric cost function is allowed to

depend on turbulent viscositydepend on turbulent viscosity

Page 22: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Modified adjoint bcs:

Continous adjoint solver

( )

ΓΓ∂

−=i

v on U

new termsnew terms

Copyright © ESI Group, 2012. All rights reserved.

( )

( ) ( )

( ) ( )

Γ=

∂⋅+⋅

∂−⋅

∂−=⋅∂⋅

⋅∂

∂−=⋅

Γ

∂+

∂+

∂+⋅+⋅=∂−

ΓΓ⋅∂

∂−=

∗∗∗

∗∗∗∗∗

sym

α

β

α

β

n

out

α

β

α

β

n

wallin

nS

gttn

S

jt

v

itvn

n

inv

nS

gn

S

j

v

ivnvnvvvnp

n

iv

on 21

on

on

,,; αηητ

ηη

τ

β

αβ

αααα

α

β

αβ

αU

Page 23: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Modified shape derivative:

Continous adjoint solver

( ) ( )∫ ⋅

∂∂

+∂

+∇⋅∇−∂

=∂

ngjj

SvvI

ϕη ααα~l

new termnew term

Copyright © ESI Group, 2012. All rights reserved.

( ) ( )∫Γ

∗ ⋅

∂+

∂+∇⋅∇−

Ω∂

∂=

Ω∂

wall

nS

gj

S

jSvv

I

t

ϕη

ηαβ

αβ

αβ

αα~l

αβ

αβηη

S

gS

∂+=~

linearized linearized

turbulent turbulent

viscosityviscosity

Page 24: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

More complications..

turbulence models (k-epsilon,Spalart-Allmaras..)

law of the wall

Continous adjoint solver

Copyright © ESI Group, 2012. All rights reserved.

natural convection (+Temperature equation)

MHD

Chemistry ..

Page 25: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Continous adjoint solver

( )( )

= 0β

β

,

,!

uR

uI

PhysicsPhysics

exact derivation

u

Iu

u

RT

∂−=

∂ ∗

Dual PhysicsDual Physics

Co

ntin

uo

us a

djo

int s

olv

er

Pri

mal so

lver

Copyright © ESI Group, 2012. All rights reserved.

dis

cre

tizati

on

consistency?

Co

ntin

uo

us a

djo

int s

olv

er

Pri

mal so

lver

CFD-ACE+Open FOAMFluent

( ) 0, =βhh uR

Discrete PhysicsDiscrete Physics

hh

T

u

Iu

u

Rh

∂−=

∂ ∗

Discrete dualDiscrete dual

dis

cre

tizatio

n

( )

=⋅∇

∇=∇⋅∇+∗

∗∗

0

2

v

pvvv µε )(*

=⋅∇

∇=∆−⊗⋅∇

0v

pvvv µNavierNavier--

StokesStokes

Page 26: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Pros:

Relatively easy-to-implement

Independant of the numerical scheme of the application code

CPU and memory efficient

Continuous adjoint solver

Copyright © ESI Group, 2012. All rights reserved.

Cons:

Gradient inconsistency: the computed adjoint state is not the adjoint state of the computed physical field

Requires by hand differentiation of the underlying physical model may be tricky (turbulence models..)

High cost maintenance: any model addendum in the primal solver requires a specific development effort counterpart in the adjoint solver

Page 27: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Enriched with converters in 2010 so that it can accomodate results of alternative CFD codes

the CFD may be run using OpenFOAM or Star-CCM+ and the adjoint using PAM-FLOW

Continuous adjoint solver

Copyright © ESI Group, 2012. All rights reserved.

Only tet mesh

Integrated within ESI Visual process environment

Both academic and industrial proof of value

Page 28: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Drag reduction: 13% after 1 optimization cycleDrag reduction: 13% after 1 optimization cycle

Continuous adjoint solver

Copyright © ESI Group, 2012. All rights reserved.

Blue: Original surfaceBlue: Original surfaceMagenta: optimized surfaceMagenta: optimized surface

Initial design

Optimized design

Drag coefficient

0.342

0.298

Predicted drag coefficient:

Cd = 0.342

Page 29: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Continuous adjoint solver

Copyright © ESI Group, 2012. All rights reserved.

-30%

Page 30: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Continuous adjoint solver

Copyright © ESI Group, 2012. All rights reserved.

Page 31: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Optimization set-up:

Discrete adjoint solver

mesh nodes mesh nodes

coordinatescoordinates

Copyright © ESI Group, 2012. All rights reserved.

( )( )

= 0uxRts

uxI

,..

,!

KKT theory: ( ) ( ) ( )uxRuuxIuuxT

,),(,,∗∗ +=l

coordinatescoordinates

DOF vector: (v1,v2,v3,p)DOF vector: (v1,v2,v3,p)

Page 32: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

KKT theory:

Discrete adjoint solver

( ) ( )0=

+∂

=∂ ∗

uuxRuxIuux

T,),(,,l

discrete

adjoint

Copyright © ESI Group, 2012. All rights reserved.

( ) ( )0=

∂+

∂=

∂ ∗u

u

uxR

u

uxI

u

uux ,),(,,ladjoint equation

( ) ( ) ∗∗

∂+

∂=

∂u

x

uxR

x

uxI

x

uuxT

,),(,,l sensitivity

vector

Page 33: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Discrete vs. Continuous shape derivative:

*u

x

R

x

I

x

TT

∂+

∂=

∂l

Discrete adjoint solver

dis

cre

ted

iscre

te

Copyright © ESI Group, 2012. All rights reserved.

xxx ∂∂∂

( ) ( )∫Γ

∗ ⋅

∂−∇⋅∇−

Ω∂

∂=

Ω∂

wall

nS

jSvv

Iϕη

αβ

αβ

ααl

dis

cre

ted

iscre

te

co

ntin

uo

us

co

ntin

uo

us

hh00 BUT:BUT:Ω∂

∂≠

∂ I

x

IT

Page 34: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Indeed:

Discrete adjoint solver

T

x

I

Ω∂

∂I Lie Lie

derivativederivative

Sensitivity Sensitivity

to the node to the node

positionspositions

Copyright © ESI Group, 2012. All rights reserved.

keep the flow / change the shapekeep the flow / change the shape advect the flow as shape changes advect the flow as shape changes

They are connected: ( ) ( )UU

Iu

u

II

x

I

wall

T

∇⋅

∂−∇⋅

∂−

Ω∂

∂→

∂ϕϕ

Page 35: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Similarily:

Discrete adjoint solver

( ) ( ) ( )

∇⋅

∂−

∇⋅

∂−

Ω∂

∂→

∂ ∗∗

∗ UuU

Ruu

u

RuRu

x

RT

wall

TT

ϕϕ ,,, *

( )

∇⋅

∂+

∂−

Ω∂

∂→

∂ ∗U

U

Iu

U

RI

x

TT

ϕ,l

Copyright © ESI Group, 2012. All rights reserved.

Hence:( )

( ) ( )

∇⋅

∂+

∂−

Ω∂

∂+

∇⋅

+

−Ω∂

→∂

∗∗

uu

Iu

u

RuR

UU

uUx

TT

wallwall

ϕ

ϕ

,,

,

Finally:

00

00

( )

∇⋅

∂+

∂−

Ω∂

∂≈

∂ ∗U

U

Iu

U

RI

x

T

wall

T

wall

ϕ,l

Page 36: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

3 choices for computing the shape derivative:

*u

x

R

x

I

x

TT

∂+

∂=

∂l

Discrete adjoint solver

dis

cre

ted

iscre

te

exactexact

Copyright © ESI Group, 2012. All rights reserved.

xxx ∂∂∂

( ) ( )∫Γ

∗ ⋅

∂−∇⋅∇−

Ω∂

∂=

Ω∂

wall

nS

jSvv

Iϕη

αβ

αβ

ααl

dis

cre

ted

iscre

teco

ntin

uo

us

co

ntin

uo

us

( )

∇⋅

∂+

∂−

Ω∂

∂≈

∂ ∗U

U

Iu

U

RI

x

T

wall

T

wall

ϕ,l

hyb

rid

hyb

rid

valid at valid at convergenceconvergence

good (?) good (?) compromise if compromise if one can not one can not easily move easily move the nodes the nodes

Page 37: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

The adjoint matrix:

Discrete adjoint solver

333

222

111

321

321

321

v

R

v

R

v

Rv

R

v

R

v

Rv

R

v

R

v

R

vvv

vvv

vvv

∂∂

∂∂

3

2

1

v

Rv

Rv

R

p

p

p

∂∂

∂∂

p

R

p

R

p

Rvvv

∂ 321

p

Rp

AA BB

B’B’ CC

==

Copyright © ESI Group, 2012. All rights reserved.

Typical block stencil:

Huge, (not so) sparse, unsymmetric, undefinite matrix

Hard to solve (saddle-point system)

Page 38: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Use an optimal preconditioner (DDM, Multigrid, Subdomain deflation)

Discrete adjoint solver

Or a segregated-like approach: ( ) n

TT

nnx

u

R

u

IxxP

∂−

∂=−+1

Copyright © ESI Group, 2012. All rights reserved.

If matrix has to be assembled, out of coring may be needed

uu ∂∂

( )( )

+

−′

−′

−=

−−

−−

I

AD

IB

I

CBDB

I

I

BDIP A

A

A

0

00

0

0

0

1

11

11

( )ADA DIAGα=

Page 39: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Discrete adjoint solver

( )( )

= 0β

β

,

,!

uR

uI

PhysicsPhysics

exact derivation

u

Iu

u

RT

∂−=

∂ ∗

Dual PhysicsDual PhysicsP

rim

al so

lver

Copyright © ESI Group, 2012. All rights reserved.

dis

cre

tizati

on

Discrete adjoint solver

Pri

mal so

lver

CFD-ACE+

( ) 0, =βhh uR

Discrete PhysicsDiscrete Physics

hh

T

u

Iu

u

Rh

∂−=

∂ ∗

Discrete dualDiscrete dual

co

nsis

ten

cy?

( )

=⋅∇

∇=∇⋅∇+∗

∗∗

0

2

v

pvvv µε )(*

exact derivation

Page 40: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Pros:

Gradient consistency: the computed adjoint state is the real adjoint of the computed physical field

Discrete adjoint solver

Copyright © ESI Group, 2012. All rights reserved.

Cons:

Depends on the very numerical scheme of the application code

How to build the discrete adjoint operator?

Page 41: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Different approaches for building the discrete adjoint operator:

By hand

Discrete adjoint solver

Copyright © ESI Group, 2012. All rights reserved.

Automatic (Algorithmic) Differentiation

Page 42: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

By hand:

Requires an exhaustive knowledge of the primal solver

Discrete adjoint solver

Copyright © ESI Group, 2012. All rights reserved.

tedious and error prone!

High maintenance cost

Each application solver adjoint derivation has to be adressed independantly

Page 43: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

By Algorithmic Differentiation:

The source code istelf is differentiated

2 modes: direct / reverse

2 approaches: source transformation / operator overloading

Discrete adjoint solver

Copyright © ESI Group, 2012. All rights reserved.

Pros & cons:

Low cost maintenance: the code is differentiated once and for all (no further effort for accomodating newly developped models in the primal solver)

But each application solver adjoint derivation has to be adressed mostly independantly

May turn to be tedious and time consuming depending on the code structure and programming language

Very invasive: requires full access to the source code

Severe CPU efficiency and memory consumption challenges

Page 44: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Academic validation against FD

Discrete adjoint solver

Dynamic library interfaced with CFD-ACE+

Copyright © ESI Group, 2012. All rights reserved.

Any mesh topology

Limitations:

Not yet parallelized

Enriched with converters so that it can accomodate results of alternative CFD codes

the CFD may be run using OpenFOAM or Star-CCM+ and the adjoint using PAM-FLOW

Page 45: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Discrete adjoint solver

A word on rigorous validation:

-step_factor*Computed_Gradient

Copyright © ESI Group, 2012. All rights reserved.

Relative error :=100* ABS(Expected_Improvement-Effective_Improvement)/Effective_Improvement

Expected Improvement := step_factor*Computed_Gradient_Norm**2

Effective Improvement := I_oldshape-I_newshape

I_oldshapeI_newshape

Page 46: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Discrete adjoint solver

Airfoil Tet

Airfoil Hex

Aifoil Hex

S-Bend (Viscart)

Ahmed Body (Viscart)

Copyright © ESI Group, 2012. All rights reserved.

Physics Laminar Laminar Frozen Turbulent

Frozen Turbulent

Frozen Turbulent

Relative error (%)

0,07 0,14 0,37 5,15 0,11

Page 47: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Discrete adjoint solver

Copyright © ESI Group, 2012. All rights reserved.

Page 48: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

At first bound interior node displacement to sruface nodes one thanks to harmonic mapping (ALE-like):

Minimizes mesh isotropic distortion

Morphing

Copyright © ESI Group, 2012. All rights reserved.

ΓΩ∂=

Γ=

=∆−

wall

wallsurf

x

xx

x

\ on 0

on

0

δ

δδ

δ

surfxKx δδ =int

Page 49: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Not good for boundary layers (anisotropic mesh)

Use rigidification instead :

Morphing

Copyright © ESI Group, 2012. All rights reserved.

( )( )

( )( )

−∈

−∈

∈−

=

1

1

1

1

nblNj

ij

nblNj

jij

nbli

i

i

xx

xxx

x

I

I

/

/

)(

δ

δwallwall

ii

j1j1

j2j2

Page 50: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Then combine Laplace and rigidification:

Morphing

=∆− x 0δ

Copyright © ESI Group, 2012. All rights reserved.

( )( )

( )( )

−∈

−∈

≤∈−

=

1

1

1

1

nblNj

ij

nblNj

jij

Nnbli

i

i

xx

xxx

x

I

I

/

/

)(

δ

δ

ΓΩ∂=

Γ=

=∆−

wall

NNbl

x

xx

x

\

)(

on 0

on

0

δ

δδ

δ

Page 51: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

For boundary nodes, apply LSQ morphing:

Sample the surface nodes

Apply LSQ operator (exact for polynomial up to

Morphing

( ) ( )j

s

i

surf yx δδ →

Copyright © ESI Group, 2012. All rights reserved.

Apply LSQ operator (exact for polynomial up to desired degree)

∑∈

Φ=Sj

j

j

ssurf xyxx )()( δδ

( )

−==Φ ∑

∈≤≤

Si

iinii xxWJx2

1)()(minarg)( λλ ε

k

nodei

kiki pxpxp ∀=∑ )()(λ subject to

Page 52: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Finally, adapt the shape derivative accordingly via chain rule:

:

Morphing

Copyright © ESI Group, 2012. All rights reserved.

∂+

∂=

s

surf

surfsurf

in

ins y

x

xx

x

xy

lll

Do not forget this step, otherwise the gradient is wrong !

:

Page 53: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Morphing option available both within PAM-FLOW Continuous Adjoint Solver and ACE+ Discrete one

Morphing

Copyright © ESI Group, 2012. All rights reserved.

:

Limited to small displacements

:

Additionaly, the tool provides the value of the maximal step factor so that all volume remain positive

:

Page 54: Continuous and Discrete adjoint methodologies within ESI CFD … · 2012. 4. 18. · Open FOAMCFD-ACE+Fluent R ... specific development effort counterpart in the adjoint solver. Enriched

Copyright © ESI Group, 2012. All rights reserved.