AIX Installation in a Partitioned Environment - Installing AIX in a Partitioned Environment
Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the...
Transcript of Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the...
![Page 1: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/1.jpg)
Solving the Partitioned Heat Equation Using FEniCS
and preCICE
Benjamin Rüth1, Peter Meisrimel2, Philipp Birken2, Benjamin Uekermann1
1Technical University of MunichDepartment of InformaticsChair of Scientific Computing
2Lund UniversityMathematics (Faculty of Sciences)Numerical Analysis
Siegen, GermanyNovember 29, 2018
![Page 2: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/2.jpg)
Agenda
Partitioned Approach
Heat Equation with FEniCS
Coupling with preCICE
Results
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 2
![Page 3: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/3.jpg)
Agenda
Partitioned Approach
Heat Equation with FEniCS
Coupling with preCICE
Results
A few Disclaimers:This talk is not• a talk about FEM• a talk about coupling algorithms• a talk with proper mathematical notation
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 2
![Page 4: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/4.jpg)
Agenda
Partitioned Approach
Heat Equation with FEniCS
Coupling with preCICE
Results
A few Disclaimers:This talk is not• a talk about FEM• a talk about coupling algorithms• a talk with proper mathematical notation
I will talk about• software• the partitioned approach• where you can find my code• how you can use my code
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 2
![Page 5: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/5.jpg)
Partitioned ApproachCoupled problems
shell and tube heat exchanger using OpenFOAM and CalculiX1
Basic idea:• reuse existing solvers• combine single-physics to solve multi-physics• only exchange "black-box" information
OF CCX OF
What we do today:
• couple with preCICE library• use FEniCS as a solver for toy problem
1Figure from Rusch, A., Uekermann, B. Comparing OpenFOAM’s Intrinsic Conjugate Heat Transfer Solver with preCICE-Coupled
Simulations. Technical Report, 2018.
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 3
![Page 6: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/6.jpg)
Partitioned ApproachCoupled problems
shell and tube heat exchanger using OpenFOAM and CalculiX1
Basic idea:• reuse existing solvers• combine single-physics to solve multi-physics• only exchange "black-box" information
OF CCX OF
What we do today:
• couple with preCICE library• use FEniCS as a solver for toy problem
1Figure from Rusch, A., Uekermann, B. Comparing OpenFOAM’s Intrinsic Conjugate Heat Transfer Solver with preCICE-Coupled
Simulations. Technical Report, 2018.
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 3
![Page 7: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/7.jpg)
Partitioned ApproachCoupled problems
shell and tube heat exchanger using OpenFOAM and CalculiX1
Basic idea:• reuse existing solvers• combine single-physics to solve multi-physics• only exchange "black-box" information
OF CCX OF
What we do today:
• couple with preCICE library• use FEniCS as a solver for toy problem1Figure from Rusch, A., Uekermann, B. Comparing OpenFOAM’s Intrinsic Conjugate Heat Transfer Solver with preCICE-Coupled
Simulations. Technical Report, 2018.
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 3
![Page 8: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/8.jpg)
Partitioned ApproachpreCICE1
Features• communication• coupling schemes• mapping• time interpolation• official adapters for OpenFOAM, SU2,...
github.com/precice
OpenFOAM FEniCS
libpreciceAdapter Adapter
1Bungartz, H.-J., et al. (2016). preCICE – A fully parallel library for multi-physics surface coupling.2Uekermann, B., et al. (2017). Official preCICE Adapters for Standard Open-Source Solvers.
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 4
![Page 9: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/9.jpg)
Partitioned ApproachpreCICE1
Adapter2
• access preCICE API• isolated layer between solver and preCICE• support component exchangeability• don’t change existing (reliable, well-tested)
code
github.com/precice
OpenFOAM FEniCS
libpreciceAdapter Adapter
1Bungartz, H.-J., et al. (2016). preCICE – A fully parallel library for multi-physics surface coupling.2Uekermann, B., et al. (2017). Official preCICE Adapters for Standard Open-Source Solvers.
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 4
![Page 10: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/10.jpg)
Partitioned ApproachFEniCS1
Software• open-source (LGPLv3)• extensive documentation• Python and C++ API• can be used for HPC• www.fenicsproject.org
Computing platform for solving PDEs
• Definition of weak forms• Finite Element basis functions• Meshing• Solving• ...
→ You can do a lot of things with FEniCS!
My goal:Develop an official preCICE adapter for FEniCS.
FEniCS book2
1Alnaes, M. S., et al. (2015). The FEniCS Project Version 1.5.2Logg, A., Mardal, K. A., & Wells, G. N. (2012). Automated solution of differential equations by the finite element method.
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 5
![Page 11: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/11.jpg)
Partitioned ApproachFEniCS1
Software• open-source (LGPLv3)• extensive documentation• Python and C++ API• can be used for HPC• www.fenicsproject.org
Computing platform for solving PDEs
• Definition of weak forms• Finite Element basis functions• Meshing• Solving• ...
→ You can do a lot of things with FEniCS!
My goal:Develop an official preCICE adapter for FEniCS. FEniCS book2
1Alnaes, M. S., et al. (2015). The FEniCS Project Version 1.5.2Logg, A., Mardal, K. A., & Wells, G. N. (2012). Automated solution of differential equations by the finite element method.
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 5
![Page 12: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/12.jpg)
Partitioned ApproachToy problem: Partitioned Heat Equation
ΓD
(0,0) (xc,0)
(xc,1)(0,1)
preCICEΓN
(xc,0) (2,0)
(2,1)(xc,1)
Partitioned heat equation / transmission problem already discussed in literature (e.g.1 or 2).
1Monge, A. (2018). Partitioned methods for time-dependent thermal fluid-structure interaction. Lund University.2Toselli, A., & Widlund, O. (2005). Domain Decomposition Methods - Algorithms and Theory (1st ed.).
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 6
![Page 13: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/13.jpg)
Heat Equation with FEniCS
Partitioned Heat Equation
get Ω1: uD = u1(x ,y)
Dirichlet BC
set Ω2: u2(x ,y) = uD
get Ω2: qN = ∂u2∂~n (x ,y)
Neumann BC
set Ω1: ∂u1∂~n (x ,y) = qN
heat equation on Ω1∂u1∂ t = ∆u1 + f
heat equation on Ω2∂u2∂ t = ∆u2 + f
FEniCS Ingredients
1. Solve Dirichlet Problem D(uD)
2. Compute heat flux D(uD) = qN
3. Solve Neumann Problem N (qN) = uD
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 7
![Page 14: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/14.jpg)
Heat Equation with FEniCS
Partitioned Heat Equation
get Ω1: uD = u1(x ,y)
Dirichlet BC
set Ω2: u2(x ,y) = uD
get Ω2: qN = ∂u2∂~n (x ,y)
Neumann BC
set Ω1: ∂u1∂~n (x ,y) = qN
heat equation on Ω1∂u1∂ t = ∆u1 + f
heat equation on Ω2∂u2∂ t = ∆u2 + f
FEniCS Ingredients
1. Solve Dirichlet Problem D(uD)
2. Compute heat flux D(uD) = qN
3. Solve Neumann Problem N (qN) = uD
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 7
![Page 15: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/15.jpg)
Heat Equation with FEniCS1. Solve Dirichlet Problem D(uD)
Heat Equation
∂u∂ t
= ∆u + f in Ω
u = u0(t) on ∂ Ω
Solution of Poisson equation. Figure from 1.
1Logg, A., Mardal, K. A., & Wells, G. N. (2012). Automated solution of differential equations by the finite element method.
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 8
![Page 16: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/16.jpg)
Heat Equation with FEniCS1. Solve Dirichlet Problem D(uD)
Discretization• implicit Euler:
uk −uk−1
dt= ∆uk + f k
• trial space:u ∈ Vh ⊂ V =
v ∈ H1 (Ω) : v = u0 on ∂ Ω
• test space:
v ∈ Vh ⊂ V =
v ∈ H1 (Ω) : v = 0 on ∂ Ω
• weak form: ∫Ω
(ukv + dt∇uk ·∇v)dx =∫Ω
(uk−1 + dt f k)vdx
Analytical SolutionIf right-hand-side f = β −2−2α we get u = 1 + x2 + αy2 + β t .
weak form in FEniCSF = u*v*dx + dt*dot(grad(u),grad(v))*dx - (u_n+dt*f)*v*dx
Remark: Tutorial from the FEniCS tutorial book1
1Langtangen, H. P., & Logg, A. (2016). Solving PDEs in Python - The FEniCS Tutorial I (1st ed.).
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 9
![Page 17: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/17.jpg)
Heat Equation with FEniCS1. Solve Dirichlet Problem D(uD)
Discretization• implicit Euler:
uk −uk−1
dt= ∆uk + f k
• trial space:u ∈ Vh ⊂ V =
v ∈ H1 (Ω) : v = u0 on ∂ Ω
• test space:
v ∈ Vh ⊂ V =
v ∈ H1 (Ω) : v = 0 on ∂ Ω
• weak form: ∫Ω
(ukv + dt∇uk ·∇v)dx =∫Ω
(uk−1 + dt f k)vdx
Analytical SolutionIf right-hand-side f = β −2−2α we get u = 1 + x2 + αy2 + β t .
weak form in FEniCSF = u*v*dx + dt*dot(grad(u),grad(v))*dx - (u_n+dt*f)*v*dx
Remark: Tutorial from the FEniCS tutorial book1
1Langtangen, H. P., & Logg, A. (2016). Solving PDEs in Python - The FEniCS Tutorial I (1st ed.).
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 9
![Page 18: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/18.jpg)
Heat Equation with FEniCS1. Solve Dirichlet Problem D(uD)
Discretization• implicit Euler:
uk −uk−1
dt= ∆uk + f k
• trial space:u ∈ Vh ⊂ V =
v ∈ H1 (Ω) : v = u0 on ∂ Ω
• test space:
v ∈ Vh ⊂ V =
v ∈ H1 (Ω) : v = 0 on ∂ Ω
• weak form: ∫Ω
(ukv + dt∇uk ·∇v)dx =∫Ω
(uk−1 + dt f k)vdx
Analytical SolutionIf right-hand-side f = β −2−2α we get u = 1 + x2 + αy2 + β t .
weak form in FEniCSF = u*v*dx + dt*dot(grad(u),grad(v))*dx - (u_n+dt*f)*v*dx
Remark: Tutorial from the FEniCS tutorial book1
1Langtangen, H. P., & Logg, A. (2016). Solving PDEs in Python - The FEniCS Tutorial I (1st ed.).
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 9
![Page 19: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/19.jpg)
Heat Equation with FEniCS2. Compute heat flux D(uD) = qN
Overall Heat Flux
Q =−K∫ΓN
∂u∂~n
ds (K : Thermal Conductivity)
Elementwise Heat Flux1
µki =
∫ΓN
∂uk
∂~nvi ds =
∫Ω
ukvi−uk−1vi + dt ∇uk ·∇vi−dt f kvidx
qN =−K ∑i
vi µki
ΓNQ
ΓN qN
1Toselli, A., & Widlund, O. (2005). Domain Decomposition Methods - Algorithms and Theory (1st ed.). p.3 f.
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 10
![Page 20: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/20.jpg)
Heat Equation with FEniCS3. Solve Neumann Problem N (qN) = uD
Neumann BC: Modified weak form∫Ω
(ukv + dt∇uk ·∇v)dx =∫Ω
(uk−1 + dt f k)vdx +
∫ΓN
qNv ds
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 11
![Page 21: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/21.jpg)
Coupling with preCICE
Partitioned Heat Equation
get Ω1: uD = u1(x ,y)
Dirichlet BC
set Ω2: u2(x ,y) = uD
get Ω2: qN = ∂u2∂~n (x ,y)
Neumann BC
set Ω1: ∂u1∂~n (x ,y) = qN
heat equation on Ω1∂u1∂ t = ∆u1 + f
heat equation on Ω2∂u2∂ t = ∆u2 + f
preCICE Ingredients
1. Read coupling data uD,qN to nodal data uD,i ,qN,i
2. Apply coupling boundary conditions uD,qN
3. preCICE-FEniCS Adapter
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 12
![Page 22: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/22.jpg)
Coupling with preCICE
Partitioned Heat Equation
get Ω1: uD = u1(x ,y)
Dirichlet BC
set Ω2: u2(x ,y) = uD
get Ω2: qN = ∂u2∂~n (x ,y)
Neumann BC
set Ω1: ∂u1∂~n (x ,y) = qN
heat equation on Ω1∂u1∂ t = ∆u1 + f
heat equation on Ω2∂u2∂ t = ∆u2 + f
preCICE Ingredients
1. Read coupling data uD,qN to nodal data uD,i ,qN,i
2. Apply coupling boundary conditions uD,qN
3. preCICE-FEniCS Adapter
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 12
![Page 23: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/23.jpg)
Coupling with preCICE1. Read Coupling Data
• Read Temperature uD: u_np1(x, y)
• Read Flux qN : fluxes(x, y)
• preCICE only accepts nodal data on the coupling mesh
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 13
![Page 24: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/24.jpg)
Coupling with preCICE2. Apply Coupling Boundary Conditions
uk
Ω1
uD,i
preCICEsample on x,y
uD
Ω2
RBF interpolation
• preCICE only returns nodal data on the coupling mesh• use RBF interpolation to create a CustomExpression(UserExpression)• Write Flux qN as Neumann BC• Write Temperature uD as Dirichlet BC
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 14
![Page 25: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/25.jpg)
Coupling with preCICE3. preCICE-FEniCS Adapter
Example usage from the perspective of the Dirichlet solver D (uD) = qN
from fenics import *from fenicsadapter import Adapter...adapter = Adapter()adapter.configure("HeatDirichlet", "precice_config.xml",
"DirichletNodes", "Flux", "Temperature")adapter.initialize(coupling_boundary, mesh, f_N_function, u_D_function)...bcs = [DirichletBC(V, u_D, remaining_boundary)]bcs.append(adapter.create_coupling_dirichlet_boundary_condition(V))...while adapter.is_coupling_ongoing():
solve(a == L, u_np1, bcs)fluxes = fluxes_from_temperature(F, V)is_converged = adapter.advance(fluxes, dt)if is_converged:
...
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 15
![Page 26: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/26.jpg)
Coupling with preCICE3. preCICE-FEniCS Adapter
Example usage from the perspective of the Dirichlet solver D (uD) = qN
from fenics import *from fenicsadapter import Adapter...adapter = Adapter()adapter.configure("HeatDirichlet", "precice_config.xml",
"DirichletNodes", "Flux", "Temperature")adapter.initialize(coupling_boundary, mesh, f_N_function, u_D_function)...bcs = [DirichletBC(V, u_D, remaining_boundary)]bcs.append(adapter.create_coupling_dirichlet_boundary_condition(V))...while adapter.is_coupling_ongoing():
solve(a == L, u_np1, bcs)fluxes = fluxes_from_temperature(F, V)is_converged = adapter.advance(fluxes, dt)if is_converged:
...
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 15
![Page 27: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/27.jpg)
Coupling with preCICE3. preCICE-FEniCS Adapter
Example usage from the perspective of the Dirichlet solver D (uD) = qN
from fenics import *from fenicsadapter import Adapter...adapter = Adapter()adapter.configure("HeatDirichlet", "precice_config.xml",
"DirichletNodes", "Flux", "Temperature")adapter.initialize(coupling_boundary, mesh, f_N_function, u_D_function)...bcs = [DirichletBC(V, u_D, remaining_boundary)]bcs.append(adapter.create_coupling_dirichlet_boundary_condition(V))...while adapter.is_coupling_ongoing():
solve(a == L, u_np1, bcs)fluxes = fluxes_from_temperature(F, V)is_converged = adapter.advance(fluxes, dt)if is_converged:
...
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 15
![Page 28: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/28.jpg)
Coupling with preCICE3. preCICE-FEniCS Adapter
Example usage from the perspective of the Dirichlet solver D (uD) = qN
from fenics import *from fenicsadapter import Adapter...adapter = Adapter()adapter.configure("HeatDirichlet", "precice_config.xml",
"DirichletNodes", "Flux", "Temperature")adapter.initialize(coupling_boundary, mesh, f_N_function, u_D_function)...bcs = [DirichletBC(V, u_D, remaining_boundary)]bcs.append(adapter.create_coupling_dirichlet_boundary_condition(V))...while adapter.is_coupling_ongoing():
solve(a == L, u_np1, bcs)fluxes = fluxes_from_temperature(F, V)is_converged = adapter.advance(fluxes, dt)if is_converged:
...
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 15
![Page 29: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/29.jpg)
Coupling with preCICE3. preCICE-FEniCS Adapter
Example usage from the perspective of the Dirichlet solver D (uD) = qN
from fenics import *from fenicsadapter import Adapter...adapter = Adapter()adapter.configure("HeatDirichlet", "precice_config.xml",
"DirichletNodes", "Flux", "Temperature")adapter.initialize(coupling_boundary, mesh, f_N_function, u_D_function)...bcs = [DirichletBC(V, u_D, remaining_boundary)]bcs.append(adapter.create_coupling_dirichlet_boundary_condition(V))...while adapter.is_coupling_ongoing():
solve(a == L, u_np1, bcs)fluxes = fluxes_from_temperature(F, V)is_converged = adapter.advance(fluxes, dt)if is_converged:
...
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 15
![Page 30: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/30.jpg)
ResultsMatching meshes
Comments• simple heat equation from above• "eyeball norm:" agreement with monolithic and analytical solution u = 1 + x2 + αy2 + β t
• L2-error on domain < 10−4
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 16
![Page 31: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/31.jpg)
ResultsMatching meshes
Comments• simple heat equation from above• "eyeball norm:" agreement with monolithic and analytical solution u = 1 + x2 + αy2 + β t• L2-error on domain < 10−4
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 16
![Page 32: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/32.jpg)
ResultsNon-matching meshes
Comments• simple heat equation from above• finer mesh on right domain, but larger error• possible explanation: first order mapping destroys second order accuracy of space discretization
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 17
![Page 33: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/33.jpg)
Summary & Outlook
Partitioned heat equation
• FEniCS is used for solving the Dirichlet and Neumann problem.• preCICE couples two FEniCS instances to solve the coupled problem.
FEniCS adapter
• only minimal changes in the official FEniCS tutorial for the heat equation1.• FEniCS adapter for heat transport• github.com/precice/fenics-adapter• github.com/precice/tutorials
Can we live with the error close to the boundary?
1Langtangen, H. P., & Logg, A. (2016). Solving PDEs in Python - The FEniCS Tutorial I (1st ed.). Sec. 3.1Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 18
![Page 34: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/34.jpg)
Summary & Outlook
Partitioned heat equation
• FEniCS is used for solving the Dirichlet and Neumann problem.• preCICE couples two FEniCS instances to solve the coupled problem.
FEniCS adapter
• only minimal changes in the official FEniCS tutorial for the heat equation1.• FEniCS adapter for heat transport• github.com/precice/fenics-adapter• github.com/precice/tutorials
Can we live with the error close to the boundary?
1Langtangen, H. P., & Logg, A. (2016). Solving PDEs in Python - The FEniCS Tutorial I (1st ed.). Sec. 3.1Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 18
![Page 35: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/35.jpg)
Summary & Outlook
Partitioned heat equation
• FEniCS is used for solving the Dirichlet and Neumann problem.• preCICE couples two FEniCS instances to solve the coupled problem.
FEniCS adapter
• only minimal changes in the official FEniCS tutorial for the heat equation1.• FEniCS adapter for heat transport• github.com/precice/fenics-adapter• github.com/precice/tutorials
Can we live with the error close to the boundary?
1Langtangen, H. P., & Logg, A. (2016). Solving PDEs in Python - The FEniCS Tutorial I (1st ed.). Sec. 3.1Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 18
![Page 36: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/36.jpg)
Summary & OutlookOutlook: FEniCS + X• first experiments with FEniCS + OpenFOAM• more FEniCS tutorials• FEniCS based solvers as CBC.Block, CBC.RANS and CBC.Solve1
Flow over heated plate. FEniCS used for solving the heat equation inside the hot plate at the bottomand OpenFOAM used for simulation of the channel flow.
Non-matching Meshes
1Logg, A., Mardal, K. A., & Wells, G. N. (2012). Automated solution of differential equations by the finite element method. Lecture
Notes in Computational Science and Engineering.
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 19
![Page 37: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/37.jpg)
Summary & OutlookOutlook: FEniCS + X• first experiments with FEniCS + OpenFOAM• more FEniCS tutorials• FEniCS based solvers as CBC.Block, CBC.RANS and CBC.Solve1
Flow over heated plate. FEniCS used for solving the heat equation inside the hot plate at the bottomand OpenFOAM used for simulation of the channel flow.
Non-matching Meshes
1Logg, A., Mardal, K. A., & Wells, G. N. (2012). Automated solution of differential equations by the finite element method. Lecture
Notes in Computational Science and Engineering.
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 19
![Page 38: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/38.jpg)
Thank You!
Website: precice.orgSource/Wiki: github.com/precice
Mailing list: precice.org/resourcesMy e-mail: [email protected]
Homework:• Follow a tutorial• Join our mailing list• Star on GitHub• Send us feedback• Ask me for stickers
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 20
![Page 39: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/39.jpg)
Dirichlet Problem with FEniCS
Heat Equation
∂u∂ t
= ∆u + f in Ω
u = u0(t) on ∂ Ω
Analytical Solution, if f = β −2−2α we getu = 1 + x2 + αy2 + β t .
Solution of Poisson equation. Figure from 1.
Discretization• implicit Euler:
uk −uk−1
dt= ∆uk + f k
• trial space:
u ∈ Vh ⊂ V =
v ∈ H1 (Ω) : v = u0 on ∂ Ω
• test space:
v ∈ Vh ⊂ V =
v ∈ H1 (Ω) : v = 0 on ∂ Ω
• weak form:∫Ω
(ukv +dt∇uk ·∇v)dx =∫Ω
(uk−1 + dt f k)vdx
Remark: Tutorial from the FEniCS book1
1Langtangen, H. P., & Logg, A. (2016). Solving PDEs in Python - The FEniCS Tutorial I (1st ed.).
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 21
![Page 40: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/40.jpg)
Dirichlet Problem with FEniCS
Geometry: Ω,∂ Ω,ΓD,ΓN
class RightBoundary(SubDomain):def inside(self, x, on_boundary):
tol = 1E-14if on_boundary
and near(x[0], x_r, tol):return True
else:return False
class Boundary(SubDomain):def inside(self, x, on_boundary):
if on_boundary:return True
else:return False
p0 = Point(0, 0)p1 = Point(1, 1)
Mesh: Ωh
nx = 5ny = 5mesh = RectangleMesh(p0, p1,
nx, ny)
Mesh created with FEniCS
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 22
![Page 41: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/41.jpg)
Dirichlet Problem with FEniCS
Function Space: Vh ⊂ V =
v ∈ H1 (Ω)
V = FunctionSpace(mesh, ’P’, 1)
Expressions: u = 1 + x2 + αy2 + β t and f = β −2−2α
u_D = Expression(’1 + x[0]*x[0] + alpha*x[1]*x[1] + beta*t’, ..., t=0)f = Constant(beta - 2 - 2 * alpha)
Boundary Conditions: u ∈ Vh ⊂ V =
v ∈ H1 (Ω) : v = uD on ∂ Ω
and v ∈ Vh ⊂ V =
v ∈ H1 (Ω) : v = 0 on ∂ Ω
bc = DirichletBC(V, u_D, Boundary)u = TrialFunction(V)v = TestFunction(V)
Initial Condition: u0 = u(t = 0)
u_n = interpolate(u_D, V)
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 23
![Page 42: Solving the Partitioned Heat Equation Using FEniCS and preCICE · 2018-12-04 · Solving the Partitioned Heat Equation Using FEniCS and preCICE Benjamin Rüth1, Peter Meisrimel2,](https://reader030.fdocuments.us/reader030/viewer/2022040722/5e30c2f2604008479747e534/html5/thumbnails/42.jpg)
Dirichlet Problem with FEniCS
Variational Problem: ∫Ω(ukv + dt∇uk ·∇v)dx =∫Ω
(uk−1 + dt f k
)vdx
F = u * v * dx + dt * dot(grad(u), grad(v)) * dx - (u_n + dt * f) * v *dx
a, L = lhs(F), rhs(F)
Time-stepping and simulation loop: uk−uk−1
dt = ∆uk + f k
u_np1 = Function(V)t = 0T = 1dt = .1u_D.t = t + dt
while t < T:solve(a == L, u_np1, bc)t += dtu_D.t = t + dtu_n.assign(u_np1)
Benjamin Rüth (TUM) | Solving the Partitioned Heat Equation Using FEniCS and preCICE 24