shapeoptimizationwithmultiplemeshesinthe fenics-framework ·...

90
Shape Optimization with Multiple Meshes in the FEniCS-framework Jørgen S. Dokken 1 , Simon W. Funke 1 , August Johansson 1 , Marie E. Rognes 1 , Stephan Schmidt 2 Simula Research Laboratory, Fornebu, Norway 1 , University of Würzburg, Würzburg, Germany 2 September 28, 2017

Upload: others

Post on 10-May-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Shape Optimization with Multiple Meshes in theFEniCS-framework

Jørgen S. Dokken1 , Simon W. Funke1, August Johansson1,Marie E. Rognes1, Stephan Schmidt2

Simula Research Laboratory, Fornebu, Norway1,University of Würzburg, Würzburg, Germany2

September 28, 2017

Page 2: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

[fenicsproject.org]

I FEniCS is a software for solving PDEs via the finite-element methodI FEniCS is an international open source software and research projectI FEniCS is user-friendly: estimated 103 − 104 users world-wideI FEniCS is efficient: parallel performant up to (at least) 25 000 cores.

2

Page 3: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

FEniCS provides automated generation of bases for a widerange of finite element spaces

from dolfin import ∗

# Import meshesmesh = Mesh("cable.xml")subdomains = MeshFunction("size t", mesh,

"cable vf.xml")

# Define finite element spacesV = FunctionSpace(mesh, "CG", 1)u = TrialFunction(V)v = TestFunction(V)T = Function(V)

# Problem specific variablesf= Expression("cos(x[0])∗exp(sin(x[1]))", degree=3)lmb = Expression("...", degree=3)T ex = 20.c = 0.01

# Define variational forma = inner(lmb∗grad(u), grad(v))∗dx+u∗v∗ds−c∗u∗v∗dxl = f∗v∗dx+T ex∗v∗ds

# Solve a(T,v) = l(v) with respect to Tsolve(a == l, T)

3

Page 4: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

FEniCS provides an expressive form language close tomathematical syntax

from dolfin import ∗

# Import meshesmesh = Mesh("cable.xml")subdomains = MeshFunction("size t", mesh,

"cable vf.xml")

# Define finite element spacesV = FunctionSpace(mesh, "CG", 1)u = TrialFunction(V)v = TestFunction(V)T = Function(V)

# Problem specific variablesf= Expression("cos(x[0])∗exp(sin(x[1]))", degree=3)lmb = Expression("...", degree=3)T ex = 20.c = 0.01

# Define variational forma = inner(lmb∗grad(u), grad(v))∗dx+u∗v∗ds−c∗u∗v∗dxl = f∗v∗dx+T ex∗v∗ds

# Solve a(T,v) = l(v) with respect to Tsolve(a == l, T)

Language for variational forms

Generality Efficiency

Code Generation

3

Page 5: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

FEniCS provides automated form evaluation and assemblyof the linear system

from dolfin import ∗

# Import meshesmesh = Mesh("cable.xml")subdomains = MeshFunction("size t", mesh,

"cable vf.xml")

# Define finite element spacesV = FunctionSpace(mesh, "CG", 1)u = TrialFunction(V)v = TestFunction(V)T = Function(V)

# Problem specific variablesf= Expression("cos(x[0])∗exp(sin(x[1]))", degree=3)lmb = Expression("...", degree=3)T ex = 20.c = 0.01

# Define variational forma = inner(lmb∗grad(u), grad(v))∗dx+u∗v∗ds−c∗u∗v∗dxl = f∗v∗dx+T ex∗v∗ds

# Solve a(T,v) = l(v) with respect to Tsolve(a == l, T)

i0

i1

i2

j0 j1 j2

1

2

3

1 2 3

A21

Automated assembly

High performance linear algebra

3

Page 6: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Mixed-dimensional methods1

1Cecile Daversin-Catty and Marie E. Rognes. “Automated abstractions forMixed-Dimensional Finite Element Methods”. In: Preparation ().

4

Page 7: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Multi-physics problems require efficent mixed-dimensionaland mixed domain coupling: emerging features in FEniCS!

# W = V(Omega H) x V(Omega H U Omega T)V = FunctionSpace(mesh, "Lagrange",1) # Heart + TorsoH = FunctionSpace(submesh heart , "Lagrange",1) # HeartW = FunctionSpaceProduct(H,V)

# v, psi v in V(Omega H)# u, psi u in V(Omega H U \Omega T)(v,u) = TrialFunction(W)(psi v ,psi u) = TestFunction(W)

# Integration on the heart domain Omega HdH = Measure("dx",domain=W.sub space(0).mesh())# Integration on the whole domain Omega H U Omega TdV = Measure("dx",domain=W.sub space(1).mesh())

# Variational formulationA = v∗psi v∗dH\

+ th∗dt∗Mi∗inner(grad(v),grad(psi v))∗dHC = (dt/th)∗(Mi+Me)∗inner(grad(u),grad(psi u))∗dV\

+ (dt/th)∗Mt∗inner(grad(u),grad(psi u))∗dVB = dt∗Mi∗inner(grad(u),grad(psi v))∗dHBT = dt∗Mi∗inner(grad(v),grad(psi u))∗dHa = A + C + B + BTL = c + d

sol = Function(W)solve(a == L, sol)

[C. Daversin-Catty, [email protected]]

5

Page 8: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Multi-physics problems require efficent mixed-dimensionaland mixed domain coupling: emerging features in FEniCS!

# W = V(Omega H) x V(Omega H U Omega T)V = FunctionSpace(mesh, "Lagrange",1) # Heart + TorsoH = FunctionSpace(submesh heart , "Lagrange",1) # HeartW = FunctionSpaceProduct(H,V)

# v, psi v in V(Omega H)# u, psi u in V(Omega H U \Omega T)(v,u) = TrialFunction(W)(psi v ,psi u) = TestFunction(W)

# Integration on the heart domain Omega HdH = Measure("dx",domain=W.sub space(0).mesh())# Integration on the whole domain Omega H U Omega TdV = Measure("dx",domain=W.sub space(1).mesh())

# Variational formulationA = v∗psi v∗dH\

+ th∗dt∗Mi∗inner(grad(v),grad(psi v))∗dHC = (dt/th)∗(Mi+Me)∗inner(grad(u),grad(psi u))∗dV\

+ (dt/th)∗Mt∗inner(grad(u),grad(psi u))∗dVB = dt∗Mi∗inner(grad(u),grad(psi v))∗dHBT = dt∗Mi∗inner(grad(v),grad(psi u))∗dHa = A + C + B + BTL = c + d

sol = Function(W)solve(a == L, sol)

[A BBT C

] [vu

]=

[cd

]φiH : V (ΩH) basis functions

φiHT : V (ΩH ∪ ΩT ) basis functions

Aij =

∫ΩH

φjHφiH + θ∆t

∫ΩH

Mi∇φjH · ∇φiH

Bij = ∆t

∫ΩH

Mi∇φjH · ∇φiHT

Cij =∆t

θ

∫ΩH

(Mi + Me)∇φjHT · ∇φiHT

+∆t

θ

∫ΩT

MT∇φjHT · ∇φiHT

[C. Daversin-Catty, [email protected]]

5

Page 9: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Multi-physics problems require efficent mixed-dimensionaland mixed domain coupling: emerging features in FEniCS!

[C. Daversin-Catty, [email protected]]

5

Page 10: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Multi-physics problems require efficent mixed-dimensionaland mixed domain coupling: emerging features in FEniCS!

[C. Daversin-Catty, [email protected]]

5

Page 11: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Multi-physics problems require efficent mixed-dimensionaland mixed domain coupling: emerging features in FEniCS!

[C. Daversin-Catty, [email protected]]

5

Page 12: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Multi-physics problems require efficent mixed-dimensionaland mixed domain coupling: emerging features in FEniCS!

[C. Daversin-Catty, [email protected]]

5

Page 13: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

CUT Finite Element Methods:MultiMesh2

2August Johansson et al. “Finite Element Methods for Arbitrary ManyIntersecting Meshes: Multimesh”. In: Preparation ().

6

Page 14: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

The computational domain is represented by an arbitrarynumber of overlapping meshes3

Kh,0

Kh,1

Λ1

Λ1

Ω0

Ω1

Ω1

Ω0

Λ1

Λ0 = Γex

3August Johansson et al. “Finite Element Methods for Arbitrary ManyIntersecting Meshes: Multimesh”. In: Preparation ().

7

Page 15: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

A finite element function space is introduced on eachindvidual mesh, ignoring completely covered cells3

Kh,0

Kh,1

Λ1

Λ1

Ωh,1

Ω1

Ω0

Λ1

Λ0 = Γex

Ωh,0

3August Johansson et al. “Finite Element Methods for Arbitrary ManyIntersecting Meshes: Multimesh”. In: Preparation ().

7

Page 16: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

We illustrate the method by considering the stationary heatequation with a reaction coefficient

−∇ · (λ∇T0)− cT0 = f in Ω0,

−∇ · (λ∇T )− cT = f in Ω,

λex∂T0

∂n+ (T0 − Tex) = 0 on Γex,

[T ]± = 0 on Γ1int ,[

λ∂T

∂n

= 0 on Γ1int .

[T ] = 0 on Λ1,[∂T

∂n

]= 0 on Λ1. Distribution of the source f in

the computational domain.

8

Page 17: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

We illustrate the method by considering the stationary heatequation with a reaction coefficient

−∇ · (λ∇T0)− cT0 = f in Ω0,

−∇ · (λ∇T )− cT = f in Ω,

λex∂T0

∂n+ (T0 − Tex) = 0 on Γex,

[T ]± = 0 on Γ1int ,[

λ∂T

∂n

= 0 on Γ1int .

[T ] = 0 on Λ1,[∂T

∂n

]= 0 on Λ1. Heat diffusion coefficient λ in

the computational domain.

8

Page 18: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Continuity of the solution is enforced over the artificialinterface Λ1

−∇ · (λ∇T0)− cT0 = f in Ω0,

−∇ · (λ∇T )− cT = f in Ω,

λex∂T0

∂n+ (T0 − Tex) = 0 on Γex,

[T ]± = 0 on Γ1int ,[

λ∂T

∂n

= 0 on Γ1int .

[T ] = 0 on Λ1,[∂T

∂n

]= 0 on Λ1.

Ω0Λ1

Ω1 = Ω1

Γ1int

Γex

Schematic of the composition ofmultiple overlapping meshes.

8

Page 19: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Continuity of the solution is enforced over the artificialinterface Λ1

−∇ · (λ∇T0)− cT0 = f in Ω0,

−∇ · (λ∇T1)− cT1 = f in Ω1,

λex∂T0

∂n+ (T0 − Tex) = 0 on Γex,

[T ]± = 0 on Γ1int ,[

λ∂T

∂n

= 0 on Γ1int

[T ] = 0 on Λ1,[∂T

∂n

]= 0 on Λ1.

Ω0Λ1

Ω1 = Ω1

Γ1int

Γex

Schematic of the composition ofmultiple overlapping meshes.

8

Page 20: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

We create a MultiCable in FEniCS by initializing theMultiMesh object and add a background mesh

from dolfin import ∗

multimesh = MultiMesh()multimesh.add(Mesh("outer cable.xml"))for i in range(num cables):

cable = Mesh("inner cable.xml")# Scale and move internal cables# ....multimesh.add(cable)

multimesh.build()

# Create function space for temperatureV = MultiMeshFunctionSpace(multimesh , "CG", 1)T = MultiMeshFunction(V, name="Temperature")u,v = TrialFunction(V), TestFunction(V)

# Problem Specific variablesf = Expression("sin(x[0]∗x[1])", degree=3)lmb = Expression("...", degree=3)T ex , c = 3.2,0.04

alpha, beta = 4.0,4.0n = FacetNormal(multimesh)h =2.0∗Circumradius(multimesh)h = (h(’+’) + h(’−’)) / 2F = inner(lmb∗grad(u), grad(v))∗dX \

−f∗v∗dX −c∗v∗u∗dX+ (u−T ex)∗v∗dsF += − inner(avg(lmb∗grad(u)), jump(v, n))∗dI \

− inner(avg(lmb∗grad(v)), jump(u, n))∗dI \+ alpha/h∗jump(u)∗jump(v)∗dI \+ beta∗inner(jump(grad(u)), jump(grad(v)))∗dO

# Assemble multimesh formA = assemble multimesh(lhs(F))b = assemble multimesh(rhs(F))solve(A, T.vector(), b, ’lu’)

9

Page 21: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

We add multiple internal cables on top of the backgroundcable

from dolfin import ∗

multimesh = MultiMesh()multimesh.add(Mesh("outer cable.xml"))for i in range(num cables):

cable = Mesh("inner cable.xml")# Scale and move internal cables# ....multimesh.add(cable)

multimesh.build()

# Create function space for temperatureV = MultiMeshFunctionSpace(multimesh , "CG", 1)T = MultiMeshFunction(V, name="Temperature")u,v = TrialFunction(V), TestFunction(V)

# Problem Specific variablesf = Expression("sin(x[0]∗x[1])", degree=3)lmb = Expression("...", degree=3)T ex , c = 3.2,0.04

alpha, beta = 4.0,4.0n = FacetNormal(multimesh)h =2.0∗Circumradius(multimesh)h = (h(’+’) + h(’−’)) / 2F = inner(lmb∗grad(u), grad(v))∗dX \

−f∗v∗dX −c∗v∗u∗dX+ (u−T ex)∗v∗dsF += − inner(avg(lmb∗grad(u)), jump(v, n))∗dI \

− inner(avg(lmb∗grad(v)), jump(u, n))∗dI \+ alpha/h∗jump(u)∗jump(v)∗dI \+ beta∗inner(jump(grad(u)), jump(grad(v)))∗dO

# Assemble multimesh formA = assemble multimesh(lhs(F))b = assemble multimesh(rhs(F))solve(A, T.vector(), b, ’lu’)

9

Page 22: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

We add multiple internal cables on top of the backgroundcable

from dolfin import ∗

multimesh = MultiMesh()multimesh.add(Mesh("outer cable.xml"))for i in range(num cables):

cable = Mesh("inner cable.xml")# Scale and move internal cables# ....multimesh.add(cable)

multimesh.build()

# Create function space for temperatureV = MultiMeshFunctionSpace(multimesh , "CG", 1)T = MultiMeshFunction(V, name="Temperature")u,v = TrialFunction(V), TestFunction(V)

# Problem Specific variablesf = Expression("sin(x[0]∗x[1])", degree=3)lmb = Expression("...", degree=3)T ex , c = 3.2,0.04

alpha, beta = 4.0,4.0n = FacetNormal(multimesh)h =2.0∗Circumradius(multimesh)h = (h(’+’) + h(’−’)) / 2F = inner(lmb∗grad(u), grad(v))∗dX \

−f∗v∗dX −c∗v∗u∗dX+ (u−T ex)∗v∗dsF += − inner(avg(lmb∗grad(u)), jump(v, n))∗dI \

− inner(avg(lmb∗grad(v)), jump(u, n))∗dI \+ alpha/h∗jump(u)∗jump(v)∗dI \+ beta∗inner(jump(grad(u)), jump(grad(v)))∗dO

# Assemble multimesh formA = assemble multimesh(lhs(F))b = assemble multimesh(rhs(F))solve(A, T.vector(), b, ’lu’)

9

Page 23: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Nitsches method for weak enforcement of boundaryconditions is used to obtain a stable finite element scheme

from dolfin import ∗

multimesh = MultiMesh()multimesh.add(Mesh("outer cable.xml"))for i in range(num cables):

cable = Mesh("inner cable.xml")# Scale and move internal cables# ....multimesh.add(cable)

multimesh.build()

# Create function space for temperatureV = MultiMeshFunctionSpace(multimesh , "CG", 1)T = MultiMeshFunction(V, name="Temperature")u,v = TrialFunction(V), TestFunction(V)

# Problem Specific variablesf = Expression("sin(x[0]∗x[1])", degree=3)lmb = Expression("...", degree=3)T ex , c = 3.2,0.04

alpha, beta = 4.0,4.0n = FacetNormal(multimesh)h =2.0∗Circumradius(multimesh)h = (h(’+’) + h(’−’)) / 2F = inner(lmb∗grad(u), grad(v))∗dX \

−f∗v∗dX −c∗v∗u∗dX+ (u−T ex)∗v∗dsF += − inner(avg(lmb∗grad(u)), jump(v, n))∗dI \

− inner(avg(lmb∗grad(v)), jump(u, n))∗dI \+ alpha/h∗jump(u)∗jump(v)∗dI \+ beta∗inner(jump(grad(u)), jump(grad(v)))∗dO

# Assemble multimesh formA = assemble multimesh(lhs(F))b = assemble multimesh(rhs(F))solve(A, T.vector(), b, ’lu’)

0 = Fs(T , v) + FN(T , v) + FO(T , v)

Fs(T , v) =1∑

i=0

∫Ωi

λ(∇T ,∇v)− cTv − fv dx

+

∫Γex

(T0 − T ex)v ds = 0

FN(T , v) = −(〈λn1 · ∇T 〉, [v ])Λ1

− ([Th], 〈λn1 · ∇v〉)Λ1 +β

h([T ], [v ])Λ1 ,

FO(T , v) = ([∇T ], [∇v ])Ωh,0∩Ω1 .

Nitsche terms Jump Average Stability on overlapFN(u, v) [w ] = w1 − w0 〈w〉 = w1+w0

2 FO(u, v)

9

Page 24: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Nitsches method for weak enforcement of boundaryconditions is used to obtain a stable finite element scheme

from dolfin import ∗

multimesh = MultiMesh()multimesh.add(Mesh("outer cable.xml"))for i in range(num cables):

cable = Mesh("inner cable.xml")# Scale and move internal cables# ....multimesh.add(cable)

multimesh.build()

# Create function space for temperatureV = MultiMeshFunctionSpace(multimesh , "CG", 1)T = MultiMeshFunction(V, name="Temperature")u,v = TrialFunction(V), TestFunction(V)

# Problem Specific variablesf = Expression("sin(x[0]∗x[1])", degree=3)lmb = Expression("...", degree=3)T ex , c = 3.2,0.04

alpha, beta = 4.0,4.0n = FacetNormal(multimesh)h =2.0∗Circumradius(multimesh)h = (h(’+’) + h(’−’)) / 2F = inner(lmb∗grad(u), grad(v))∗dX \

−f∗v∗dX −c∗v∗u∗dX+ (u−T ex)∗v∗dsF += − inner(avg(lmb∗grad(u)), jump(v, n))∗dI \

− inner(avg(lmb∗grad(v)), jump(u, n))∗dI \+ alpha/h∗jump(u)∗jump(v)∗dI \+ beta∗inner(jump(grad(u)), jump(grad(v)))∗dO

# Assemble multimesh formA = assemble multimesh(lhs(F))b = assemble multimesh(rhs(F))solve(A, T.vector(), b, ’lu’)

0 = Fs(T , v) + FN(T , v) + FO(T , v)

Fs(T , v) =1∑

i=0

∫Ωi

λ(∇T ,∇v)− cTv − fv dx

+

∫Γex

(T0 − T ex)v ds = 0

FN(T , v) = −(〈λn1 · ∇T 〉, [v ])Λ1

− ([Th], 〈λn1 · ∇v〉)Λ1 +β

h([T ], [v ])Λ1 ,

FO(T , v) = ([∇T ], [∇v ])Ωh,0∩Ω1 .

Nitsche terms Jump Average Stability on overlapFN(u, v) [w ] = w1 − w0 〈w〉 = w1+w0

2 FO(u, v)

9

Page 25: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Nitsches method for weak enforcement of boundaryconditions is used to obtain a stable finite element scheme

from dolfin import ∗

multimesh = MultiMesh()multimesh.add(Mesh("outer cable.xml"))for i in range(num cables):

cable = Mesh("inner cable.xml")# Scale and move internal cables# ....multimesh.add(cable)

multimesh.build()

# Create function space for temperatureV = MultiMeshFunctionSpace(multimesh , "CG", 1)T = MultiMeshFunction(V, name="Temperature")u,v = TrialFunction(V), TestFunction(V)

# Problem Specific variablesf = Expression("sin(x[0]∗x[1])", degree=3)lmb = Expression("...", degree=3)T ex , c = 3.2,0.04

alpha, beta = 4.0,4.0n = FacetNormal(multimesh)h =2.0∗Circumradius(multimesh)h = (h(’+’) + h(’−’)) / 2F = inner(lmb∗grad(u), grad(v))∗dX \

−f∗v∗dX −c∗v∗u∗dX+ (u−T ex)∗v∗dsF += − inner(avg(lmb∗grad(u)), jump(v, n))∗dI \

− inner(avg(lmb∗grad(v)), jump(u, n))∗dI \+ alpha/h∗jump(u)∗jump(v)∗dI \+ beta∗inner(jump(grad(u)), jump(grad(v)))∗dO

# Assemble multimesh formA = assemble multimesh(lhs(F))b = assemble multimesh(rhs(F))solve(A, T.vector(), b, ’lu’)

0 = Fs(T , v) + FN(T , v) + FO(T , v)

Fs(T , v) =1∑

i=0

∫Ωi

λ(∇T ,∇v)− cTv − fv dx

+

∫Γex

(T0 − T ex)v ds = 0

FN(T , v) = −(〈λn1 · ∇T 〉, [v ])Λ1

− ([Th], 〈λn1 · ∇v〉)Λ1 +β

h([T ], [v ])Λ1 ,

FO(T , v) = ([∇T ], [∇v ])Ωh,0∩Ω1 .

Nitsche terms Jump Average Stability on overlapFN(u, v) [w ] = w1 − w0 〈w〉 = w1+w0

2 FO(u, v)

9

Page 26: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Shape-optimization WithOverlapping Domains4

4Jørgen S. Dokken et al. “Shape Optimization on Multiple Meshes”. In:Preparation ().

10

Page 27: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Re-meshing guarantees good mesh-quality, but it is a verycostly operation

11

Page 28: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Re-meshing guarantees good mesh-quality, but it is a verycostly operation

11

Page 29: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Re-meshing guarantees good mesh-quality, but it is a verycostly operation

11

Page 30: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Deformation of the mesh is cheaper than re-meshing butdegenerates for large changes

12

Page 31: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Deformation of the mesh is cheaper than re-meshing butdegenerates for large changes

12

Page 32: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Deformation of the mesh is cheaper than re-meshing butdegenerates for large changes

12

Page 33: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Multiple overlapping meshes is very efficient and preservesmesh quality

13

Page 34: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Multiple overlapping meshes is very efficient and preservesmesh quality

13

Page 35: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Multiple overlapping meshes is very efficient and preservesmesh quality

13

Page 36: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

We propose a new algorithm for solving PDE-constrainedshape optimization problems

minu,Ω

J(u,Ω) s.t. E (u,Ω) = 0.

Algorithm: Shape-optimization on multiple domains

Init : Domain composition Ω0 = ∪i=0,...NΩ0i

Param: k = 0while not converged do

Solve state equations on Ωk ;Compute the shape-derivatives dJ/dΩ;Update the subdomains,Ωk+1

i , i = 0, . . .N;Increment k and set Ωk = ∪i=0,...NΩk

i ;endResult: Optimized domain

14

Page 37: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

We propose a new algorithm for solving PDE-constrainedshape optimization problems

minu,Ω

J(u,Ω) s.t. E (u,Ω) = 0.

Algorithm: Shape-optimization on multiple domains

Init : Domain composition Ω0 = ∪i=0,...NΩ0i

Param: k = 0while not converged do

Solve state equations on Ωk ;Compute the shape-derivatives dJ/dΩ;Update the subdomains,Ωk+1

i , i = 0, . . .N;Increment k and set Ωk = ∪i=0,...NΩk

i ;endResult: Optimized domain

14

Page 38: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

We propose a new algorithm for solving PDE-constrainedshape optimization problems

minu,Ω

J(u,Ω) s.t. E (u,Ω) = 0.

Algorithm: Shape-optimization on multiple domains

Init : Domain composition Ω0 = ∪i=0,...NΩ0i

Param: k = 0while not converged do

Solve state equations on Ωk ;Compute the shape-derivatives dJ/dΩ;Update the subdomains,Ωk+1

i , i = 0, . . .N;Increment k and set Ωk = ∪i=0,...NΩk

i ;endResult: Optimized domain

14

Page 39: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

We propose a new algorithm for solving PDE-constrainedshape optimization problems

minu,Ω

J(u,Ω) s.t. E (u,Ω) = 0.

Algorithm: Shape-optimization on multiple domains

Init : Domain composition Ω0 = ∪i=0,...NΩ0i

Param: k = 0while not converged do

Solve state equations on Ωk ;Compute the shape-derivatives dJ/dΩ;Update the subdomains,Ωk+1

i , i = 0, . . .N;Increment k and set Ωk = ∪i=0,...NΩk

i ;endResult: Optimized domain

14

Page 40: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

We propose a new algorithm for solving PDE-constrainedshape optimization problems

minu,Ω

J(u,Ω) s.t. E (u,Ω) = 0.

Algorithm: Shape-optimization on multiple domains

Init : Domain composition Ω0 = ∪i=0,...NΩ0i

Param: k = 0while not converged do

Solve state equations on Ωk ;Compute the shape-derivatives dJ/dΩ;Update the subdomains,Ωk+1

i , i = 0, . . .N;Increment k and set Ωk = ∪i=0,...NΩk

i ;endResult: Optimized domain

14

Page 41: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

We propose a new algorithm for solving PDE-constrainedshape optimization problems

minu,Ω

J(u,Ω) s.t. E (u,Ω) = 0.

Algorithm: Shape-optimization on multiple domains

Init : Domain composition Ω0 = ∪i=0,...NΩ0i

Param: k = 0while not converged do

Solve state equations on Ωk ;Compute the shape-derivatives dJ/dΩ;Update the subdomains,Ωk+1

i , i = 0, . . .N;Increment k and set Ωk = ∪i=0,...NΩk

i ;endResult: Optimized domain

14

Page 42: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

The solution of an optimization problem with three identicalcables is an equilateral triangle

minΩ,T

J(Ω,T ) =

∫Ω

13|T |3dx ,

subject to

−∇ · (λ∇T )− cT = f in Ω,

∂T

∂n+ (T − Tamb) = 0 on Γex.

[T ]± = 0 on Γint ,[λ∂T

∂n

= 0 on Γint

Three cables with the samethermal diffusivity.

15

Page 43: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

The solution of an optimization problem with three identicalcables is an equilateral triangle

minΩ,T

J(Ω,T ) =

∫Ω

13|T |3dx ,

subject to

−∇ · (λ∇T )− cT = f in Ω,

∂T

∂n+ (T − Tamb) = 0 on Γex.

[T ]± = 0 on Γint ,[λ∂T

∂n

= 0 on Γint

Initial cable positioning andcorresponding temperature.

15

Page 44: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

The solution of an optimization problem with three identicalcables is an equilateral triangle

minΩ,T

J(Ω,T ) =

∫Ω

13|T |3dx ,

subject to

−∇ · (λ∇T )− cT = f in Ω,

∂T

∂n+ (T − Tamb) = 0 on Γex.

[T ]± = 0 on Γint ,[λ∂T

∂n

= 0 on Γint

Optimal cable distribution andtemperature.

15

Page 45: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

A benchmark problem in shape-optimization is the optimalshape of an obstacle in Stokes-flow5

min(u,Ω)

: J(Ω) =

∫Ω

2∑i ,j=1

(∂ui∂xj

)2

dA

subject to

−∆u +∇p = 0 in Ω,

∇ · u = 0,u = 0 on Γ2,

u = u0 on Γ1 ∪ Γ3,

p = 0 on Γ4,

C = C0,

Vol = Vol0.

Γ1

Γ1

Γ2Γ3

Γ4

Initial setup of the domain.

5Olivier Pironneau. “On optimum design in fluid mechanics”. In: Journalof Fluid Mechanics 64.1 (1974), pp. 97–110.

16

Page 46: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

We achieve the analytical shape, a rugby-ball with a 90degree front and back angle5

min(u,Ω)

: J(Ω) =

∫Ω

2∑i ,j=1

(∂ui∂xj

)2

dA

subject to

−∆u +∇p = 0 in Ω,

∇ · u = 0,u = 0 on Γ2,

u = u0 on Γ1 ∪ Γ3,

p = 0 on Γ4,

C = C0,

Vol = Vol0.

5Olivier Pironneau. “On optimum design in fluid mechanics”. In: Journalof Fluid Mechanics 64.1 (1974), pp. 97–110.

16

Page 47: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

With multiple meshes, we can reduce the size of the meshthat has to be deformed

16

Page 48: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

With multiple meshes, we can reduce the size of the meshthat has to be deformed

16

Page 49: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

With multiple meshes, we can reduce the size of the meshthat has to be deformed

16

Page 50: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Further work

I Extend the multiple meshformulation to to timedependent problems such asthe NS-equation.

I Use shape-optimization tooptimize power-output of atidal turbine farm. [islayenergytrust.org.uk/tidal-energy-project/]

17

Page 51: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Further work

I Extend the multiple meshformulation to to timedependent problems such asthe NS-equation.

I Use shape-optimization tooptimize power-output of atidal turbine farm. [islayenergytrust.org.uk/tidal-energy-project/]

17

Page 52: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Concluding, FEniCS is currently being extended to employmixed-domain method and CUT-FEM, where the latter hasbeen used for avoiding re-meshing in shape-optimization

10.849

21.698

32.547

0.0

43.4T

Questions?

This project is funded by the

18

Page 53: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Concluding, FEniCS is currently being extended to employmixed-domain method and CUT-FEM, where the latter hasbeen used for avoiding re-meshing in shape-optimization

10.849

21.698

32.547

0.0

43.4T

Questions?

This project is funded by the

18

Page 54: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Invisible slide

19

Page 55: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

This trend is clear for both finer and coarser meshes.

20

Page 56: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

The shape-derivative of a functional constrained by PDEs isfound with the adjoint method and shape-calculus

minΩ

J(u,Ω) s.t. E (u,Ω) = 0,

J(Ω) = J(u(Ω),Ω)

Lagrangian based adjoint equation

L(u,Ω) = J(u,Ω) + (λ,E (u(Ω),Ω)).

dJ(Ω)[s] =∂L∂Ω

[s] =∂J

∂Ω[s] +

(λ,∂E

∂Ω[s]

),

∂L∂T

=∂J

∂T[d ] +

(λ,∂E

∂T[d ]

)= 0, ∀d .

21

Page 57: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

The shape-derivative of a functional constrained by PDEs isfound with the adjoint method and shape-calculus

minΩ

J(u,Ω) s.t. E (u,Ω) = 0,

J(Ω) = J(u(Ω),Ω)

Lagrangian based adjoint equation

L(u,Ω) = J(u,Ω) + (λ,E (u(Ω),Ω)).

dJ(Ω)[s] =∂L∂Ω

[s] =∂J

∂Ω[s] +

(λ,∂E

∂Ω[s]

),

∂L∂u

=∂J

∂u[d ] +

(λ,∂E

∂u[d ]

)= 0, ∀d .

21

Page 58: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

A linear state equation yields an adjoint equation similar tothe state equation

L(u,Ω) = J(u,Ω) + (λ,E (u(Ω),Ω)).

∂J

∂u[d ] +

(λ,∂E

∂u[d ]

)= 0, ∀d .

E (u) = Au + b,(λ∂E

∂u[d ]

)= (λ,Ad).

22

Page 59: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

A linear state equation yields an adjoint equation similar tothe state equation

L(u,Ω) = J(u,Ω) + (λ,E (u(Ω),Ω)).

∂J

∂u[d ] +

(λ,∂E

∂u[d ]

)= 0, ∀d .

E (u) = Au + b,(λ∂E

∂u[d ]

)= (λ,Ad).

22

Page 60: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

The shape-derivative is transformed into surface integralswith the Hadamard theorem

L(u,Ω) = J(u,Ω) + (λ,E (u(Ω),Ω)).

dJ(Ω)[s] =∂L∂Ω

[s] =∂J

∂Ω[s] +

(λ,∂E

∂Ω[s]

),

Theorem (Hadamard Theorem)

Let J be shape differentiable. Then the relation

dJ(Ω)[V ] =

∫Γ〈V , n〉g dS

holds for all vector fields.23

Page 61: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

The shape-derivative is transformed into surface integralswith the Hadamard theorem

L(u,Ω) = J(u,Ω) + (λ,E (u(Ω),Ω)).

dJ(Ω)[s] =∂L∂Ω

[s] =∂J

∂Ω[s] +

(λ,∂E

∂Ω[s]

),

Theorem (Hadamard Theorem)

Let J be shape differentiable. Then the relation

dJ(Ω)[V ] =

∫Γ〈V , n〉g dS

holds for all vector fields.23

Page 62: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

We consider minimization of the temperature incurrent-carrying MultiCables as a first example

minΩ,T

J(Ω,T ) =

∫Ω

13|T |3dx ,

subject to

−∇ · (λ∇T )− cT = f in Ω,

∂T

∂n+ (T − Tamb) = 0 on Γex,

[T ]± = 0 on Γ1int ,[

λ∂T

∂n

= 0 on Γ1int .

Three cables with the samethermal diffusivity.

24

Page 63: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

We consider minimization of the temperature incurrent-carrying MultiCables as a first example

minΩ,T

J(Ω,T ) =

∫Ω

13|T |3dx ,

subject to

−∇ · (λ∇T )− cT = f in Ω,

∂T

∂n+ (T − Tamb) = 0 on Γex,

[T ]± = 0 on Γ1int ,[

λ∂T

∂n

= 0 on Γ1int .

Initial cable positioning andcorresponding temperature.

24

Page 64: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

We consider minimization of the temperature incurrent-carrying MultiCables as a first example

minΩ,T

J(Ω,T ) =

∫Ω

13|T |3dx ,

subject to

−∇ · (λ∇T )− cT = f in Ω,

∂T

∂n+ (T − Tamb) = 0 on Γex,

[T ]± = 0 on Γ1int ,[

λ∂T

∂n

= 0 on Γ1int .

10.849

21.698

32.547

0.0

43.4T

Optimal cable distribution andtemperature.

24

Page 65: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

The multiple meshes strong formulation has additionalterms for continuity over the artificial interface Λ1

−∇ · (λ∇T0)− cT0 = f in Ω0,

−∇ · (λ∇T )− cT = f in Ω,

λex∂T0

∂n+ (T0 − Tex) = 0 on Γex,

[T ]± = 0 on Γ1int ,[

λ∂T

∂n

= 0 on Γ1int .

[u] = 0 on Λ1,[∂u

∂n

]= 0 on Λ1.

Ω0Λ1

Ω1 = Ω1

Γ1int

Γex

25

Page 66: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

The multiple meshes strong formulation has additionalterms for continuity over the artificial interface Λ1

−∇ · (λ∇T0)− cT0 = f in Ω0,

−∇ · (λ∇T1)− cT1 = f in Ω1,

λex∂T0

∂n+ (T0 − Tex) = 0 on Γex,

[T ]± = 0 on Γ1int ,[

λ∂T

∂n

= 0 on Γ1int

[u] = 0 on Λ1,[∂u

∂n

]= 0 on Λ1.

Ω0Λ1

Ω1 = Ω1

Γ1int

Γex

26

Page 67: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Nitsches method for weak enforcement of boundaryconditions is used to obtain a stable finite element scheme

0 = Fs(T , v)

Fs(T , v) =

∫Ωλ(∇T ,∇v)− cTv − fv dx

1∑i=0

+

∫Γex

(T − T ex)v ds = 0

FS(T , v) = −(〈n1 · ∇T 〉, [v ])Λ1 − ([Th], 〈n1 · ∇v〉)Λ1 +β

h([T ], [v ])Λ1 ,

FO(T , v) = ([∇T ], [∇v ])Ωh,0∩Ω1 ,

Nitsche terms Jump Stability on overlap AverageFN(u, v) [w ] = w1 − w0 FO(u, v) 〈w〉 = w1+w0

2

27

Page 68: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Nitsches method for weak enforcement of boundaryconditions is used to obtain a stable finite element scheme

0 = Fs(T , v)

Fs(T , v) =1∑

i=0

∫Ωi

λ(∇T ,∇v)− cTv − fv dx

+

∫Γex

(T0 − T ex)v ds = 0

FS(T , v) = −(〈n1 · ∇T 〉, [v ])Λ1 − ([Th], 〈n1 · ∇v〉)Λ1 +β

h([T ], [v ])Λ1 ,

FO(T , v) = ([∇T ], [∇v ])Ωh,0∩Ω1 ,

Nitsche terms Jump Stability on overlap AverageFN(u, v) [w ] = w1 − w0 FO(u, v) 〈w〉 = w1+w0

2

27

Page 69: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Nitsches method for weak enforcement of boundaryconditions is used to obtain a stable finite element scheme

0 = Fs(T , v) + FN(T , v)

Fs(T , v) =1∑

i=0

∫Ωi

λ(∇T ,∇v)− cTv − fv dx

+

∫Γex

(T0 − T ex)v ds = 0

FN(T , v) = −(〈n1 · ∇T 〉, [v ])Λ1 − ([Th], 〈n1 · ∇v〉)Λ1 +β

h([T ], [v ])Λ1 ,

FO(T , v) = ([∇T ], [∇v ])Ωh,0∩Ω1 ,

Nitsche terms Jump Average Stability on overlapFN(u, v) [w ] = w1 − w0 〈w〉 = w1+w0

2 FO(u, v)

27

Page 70: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Nitsches method for weak enforcement of boundaryconditions is used to obtain a stable finite element scheme

0 = Fs(T , v) + FN(T , v) + FO(T , v)

Fs(T , v) =1∑

i=0

∫Ωi

λ(∇T ,∇v)− cTv − fv dx

+

∫Γex

(T0 − T ex)v ds = 0

FN(T , v) = −(〈n1 · ∇T 〉, [v ])Λ1 − ([Th], 〈n1 · ∇v〉)Λ1 +β

h([T ], [v ])Λ1 ,

FO(T , v) = ([λ∇T ], [∇v ])Ωh,0∩Ω1 .

Nitsche terms Jump Average Stability on overlapFN(u, v) [w ] = w1 − w0 〈w〉 = w1+w0

2 FO(u, v)

27

Page 71: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

The implementation of the shape-gradient is verified with aTaylor-test

28

Page 72: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

A first example is three internal cables with the samematerial properties

minΩ,T

J(Ω,T ) =

∫Ω

13|T |3dx ,

subject to

−∇ · (λ∇T )− cT = f in Ω,

∂T

∂n+ (T − Tamb) = 0 on Γex.

[T ]± = 0 on Γ1int ,[

λ∂T

∂n

= 0 on Γ1int

Three cables with the samethermal diffusivity.

29

Page 73: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

A first example is three internal cables with the samematerial properties

minΩ,T

J(Ω,T ) =

∫Ω

13|T |3dx ,

subject to

−∇ · (λ∇T )− cT = f in Ω,

∂T

∂n+ (T − Tamb) = 0 on Γex.

[T ]± = 0 on Γ1int ,[

λ∂T

∂n

= 0 on Γ1int

Initial cable positioning andcorresponding temperature.

29

Page 74: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

A first example is three internal cables with the samematerial properties

minΩ,T

J(Ω,T ) =

∫Ω

13|T |3dx ,

subject to

−∇ · (λ∇T )− cT = f in Ω,

∂T

∂n+ (T − Tamb) = 0 on Γex.

[T ]± = 0 on Γ1int ,[

λ∂T

∂n

= 0 on Γ1int

Optimal cable distribution andtemperature.

29

Page 75: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

Optimization of a more complex example with 5 cables withdifferent currents and sizes

30

Page 76: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

The state-equation has been implemented in FEniCS andverified by the method of manufactured solutions

MultiMesh SingleMeshMesh size L2-error Rate Mesh size L2-error Rate0.059 2.41e-04 2.116 0.062 2.27e-04 2.0080.030 5.92e-05 2.067 0.031 5.65e-05 2.0030.015 1.46e-05 2.055 0.016 1.41e-05 2.0020.008 3.68e-06 1.999 0.008 3.52e-06 2.001

Table: Convergence rates of a manufactured Poisson problem.Comparison between MultiMesh and the same mesh described as a singlemesh approximated by piece-wise continuous linear elements.

31

Page 77: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

The adjoint system for overlapping meshes has the samestabilization at the artificial interface as the state equationat the interface

N∑i=0

(λ∇p,∇v)Ωi

− (cp, v)Ωi

)+ (α′(T )(T − T ex)p, v)Γex + (α(T )p, v)Γex = −

N∑i=0

(T |T |, v)Ωi.

+N∑i=1

(− (〈λni · ∇p, 〉[v ])Λi

− ([p], 〈λni · ∇, v〉)Λi+ (

β

h[p], [v ])Λi

+ ([∇p], [∇v ])Ωh,0∩Ωi

)= −

N∑i=0

(T |T |, v)Ωi.

Standard terms Nitsche terms Overlap terms32

Page 78: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

The adjoint system for overlapping meshes has the samestabilization at the artificial interface as the state equationat the interface

N∑i=0

(λ∇p,∇v)Ωi

− (cp, v)Ωi

)+ (α′(T )(T − T ex)p, v)Γex + (α(T )p, v)Γex = −

N∑i=0

(T |T |, v)Ωi.

+N∑i=1

(− (〈λni · ∇p, 〉[v ])Λi

− ([p], 〈λni · ∇v〉)Λi+ (

β

h[p], [v ])Λi

)= −

N∑i=0

(T |T |, v)Ωi.

Standard terms Nitsche terms Overlap terms32

Page 79: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

The adjoint system for overlapping meshes has the samestabilization at the artificial interface as the state equationat the interface

N∑i=0

(λ∇p,∇v)Ωi

− (cp, v)Ωi

)+ (α′(T )(T − T ex)p, v)Γex + (α(T )p, v)Γex = −

N∑i=0

(T |T |, v)Ωi.

+N∑i=1

(− (〈λni · ∇p, 〉[v ])Λi

− ([p], 〈λni · ∇v〉)Λi+ (

β

h[p], [v ])Λi

+ ([λ∇p], [∇v ])Ωh,0∩Ωi

)= −

N∑i=0

(T |T |, v)Ωi.

Standard terms Nitsche terms Overlap terms32

Page 80: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

A Laplacian deformation scheme is not suited for largedeformations

−∆w = 0 in Ω,

w = d · n on Γ,

w = 0 on ∂Ω\Γ.

Γ d · nMoving Boundary Deformation

33

Page 81: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

The Eikonal convection equation ensures better mesh-quality

−h∆ε1 + ||∇ε1||22 = 1 in Ω,

ε1 = 0 on ∂Ω\Γ−h∆ε2 + ||∇ε2||22 = 1 in Ω,

ε2 = 0 on Γ

−αε22∆w + div(ε1w ⊗∇ε2) = 0w = d · n on Γ

w = 0 on partialΩ\Γ.

Γ ε1 ε2Moving Boundary Dist. to Γ Dist. to ∂Ω\Γ.

34

Page 82: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

The Eikonal convection equation ensures better mesh-quality

−h∆ε1 + ||∇ε1||22 = 1 in Ω,

ε1 = 0 on ∂Ω\Γ−h∆ε2 + ||∇ε2||22 = 1 in Ω,

ε2 = 0 on Γ

−αε22∆w + div(ε1w ⊗∇ε2) = 0w = d · n on Γ

w = 0 on ∂Ω\Γ.

Γ ε1 ε2Moving Boundary Dist. to Γ Dist. to ∂Ω\Γ.

34

Page 83: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

The Eikonal convection equation ensures better mesh-quality

−h∆ε1 + ||∇ε1||22 = 1 in Ω,

ε1 = 0 on ∂Ω\Γ−h∆ε2 + ||∇ε2||22 = 1 in Ω,

ε2 = 0 on Γ

−αε22∆w + div(ε1w ⊗∇ε2) = 0w = d · n on Γ

w = 0 on ∂Ω\Γ.

Γ ε1 ε2Moving Boundary Dist. to Γ Dist. to ∂Ω\Γ.

34

Page 84: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

In the discrete case, the solution of a state equation u isdependent of volume nodes

n

J(u(Ω),Ω) =

∫Ωu2dΩ

dJ(u(Ω),Ω)[V ] =d

(∫Ωu2dΩ

)[V ],

V = Displacement function

35

Page 85: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

In the discrete case, the solution of a state equation u isdependent of volume nodes

n

J(u(Ω),Ω) =

∫Ωu2dΩ

dJ(u(Ω),Ω)[V ] =d

(∫Ωu2dΩ

)[V ],

V = Displacement function

35

Page 86: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

The new strong formulation now has additional terms forcontinuity over the artificial interface Λ1

−∆ui = f in Ωi , i = 0, 1,

u1 +∂u1

∂n= 1 on Γ,

u0 +∂u0

∂n= 1 on ∂Ω

[u] = 0 on Λ1,[∂u

∂n

]= on Λ1,

Λ0 = ∂ΩΩ0

Γ

Λ1

Ω1

36

Page 87: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

We need several extra terms to obtain a stable FiniteElement scheme

0 = as(u, v)− ls(v)

as(u, v) = (∇u,∇v)Ω + (u, v)∂Ω + (u, v)Γ,

1∑i=0

1∑i=0

ls(v) = (f , v)Ω + (1, v)∂Ω + (1, v)Γ

1∑i=0

aN(u, v) = −(〈n1 · ∇u〉, [v ])Λ1 − ([uh], 〈n1 · ∇v〉)Λ1 +β

h([u], [v ])Λ1 ,

aO(u, v) = ([∇u], [∇v ])Ωh,0∩Ω1 ,

Nitsche terms Jump Stability on overlap AverageaN(u, v) [w ] = w1 − w0 aO(u, v) 〈w〉 = w1+w0

2

37

Page 88: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

We need several extra terms to obtain a stable FiniteElement scheme

0 = as(u, v)− ls(v)

as(u, v) =1∑

i=0

[(∇u,∇v)Ωi] + (u0, v0)∂Ω + (u1, v1)Γ,

ls(v) =1∑

i=0

(f , v)Ωi+ (1, v0)∂Ω + (1, v1)Γ.

aN(u, v) = −(〈n1 · ∇u〉, [v ])Λ1 − ([uh], 〈n1 · ∇v〉)Λ1 +β

h([u], [v ])Λ1 ,

aO(u, v) = ([∇u], [∇v ])Ωh,0∩Ω1 ,

Nitsche terms Jump Stability on overlap AverageaN(u, v) [w ] = w1 − w0 aO(u, v) 〈w〉 = w1+w0

2

37

Page 89: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

We need several extra terms to obtain a stable FiniteElement scheme

0 = as(u, v)− ls(v)

as(u, v) =1∑

i=0

[(∇u,∇v)Ωi] + (u0, v0)∂Ω + (u1, v1)Γ,

ls(v) =1∑

i=0

(f , v)Ωi+ (1, v0)∂Ω + (1, v1)Γ.

aN(u, v) = −(〈n1 · ∇u〉, [v ])Λ1 − ([uh], 〈n1 · ∇v〉)Λ1 +β

h([u], [v ])Λ1 ,

aO(u, v) = ([∇u], [∇v ])Ωh,0∩Ω1 ,

Nitsche terms Jump Average Stability on overlapaN(u, v) [w ] = w1 − w0 〈w〉 = w1+w0

2 aO(u, v)

37

Page 90: ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework · ShapeOptimizationwithMultipleMeshesinthe FEniCS-framework JørgenS.Dokken1,SimonW.Funke1,AugustJohansson1, MarieE.Rognes1,StephanSchmidt2

We need several extra terms to obtain a stable FiniteElement scheme

0 = as(u, v)− ls(v)

as(u, v) =1∑

i=0

[(∇u,∇v)Ωi] + (u0, v0)∂Ω + (u1, v1)Γ,

ls(v) =1∑

i=0

(f , v)Ωi+ (1, v0)∂Ω + (1, v1)Γ.

aN(u, v) = −(〈n1 · ∇u〉, [v ])Λ1 − ([uh], 〈n1 · ∇v〉)Λ1 +β

h([u], [v ])Λ1 ,

aO(u, v) = ([∇u], [∇v ])Ωh,0∩Ω1 ,

Nitsche terms Jump Average Stability on overlapaN(u, v) [w ] = w1 − w0 〈w〉 = w1+w0

2 aO(u, v)

37