Couple OpenFOAM with any other solver using preCICE
Gerasimos Chourdakis et al.
Technical University of Munich Department of Informatics Chair of Scientific Computing in Computer Science
2nd German OpenFoam User meetiNg TU Braunschweig February 21, 2018 Part II:
+
Agenda
Part I:
+
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN22 Agenda
Part I:
+
Part II:
+
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN22 How to simulate this heat exchanger?
Geometry of a shell-and-tube heat exchanger (Image by L. Cheung Yau, 2016)
Surface plot and streamlines of the two fluids colored by temperature. Solid not shown. Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN23 A shell-and-tube heat exchanger with preCICE
Coupling interfaces (Image by L. Cheung Yau, 2016)
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN24 preCICE precise Code Interaction Coupling Environment
libprecice Communication adapter Data Mapping Coupling Schemes Solver A Solver B
• Free (GNU LGPL), developed at TU Munich & Univ. of Stuttgart. • Version 1.0 in November 2017 (10+ years, 3 PhD generations). • Official adapters for CalculiX, Code_Aster, COMSOL, Fluent, OpenFOAM, SU2
• Third-party adapters for Ateles, Alya, Carat++, FASTEST, FEAP, foam-extend, ... • API in C, C++, Fortran, Python
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN25 But why preCICE?
libprecice Ope nFOAM CHT
adapter CalculiX
in-house FSI solver
• Pure library approach → flexibility • Fully parallel, peer-to-peer concept → scalable and efficient communication • Sophisticated and robust quasi-Newton coupling algorithms • Multi-coupling
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN26 The roles of an adapter
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN27 Part IIa: previous approach
+
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN28 Duplicated development effort
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN29 Duplicated development effort
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN29 Duplicated development effort
All these adapters are bound to specific solvers!
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN29 Duplicated development effort
All these adapters are bound to specific solvers! → We need an official, general adapter!
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN29 Example of an adapted solver (previous)
1 /* Adapter: Initialize coupling */ 22 /* solve the equations */
2 adapter.initialize(); 23 #include "rhoEqn.H"
3 24 while (pimple.loop())
4 Info<<"\nStarting time loop\n" << endl; 25 {
5 26 ...
6 while (adapter.isCouplingOngoing()) { 27 }
7 #include "readTimeControls.H" 28
8 #include "compressibleCourantNo.H" 29 /* Adapter: Write in buffers */
9 #include "setDeltaT.H" 30 adapter.writeCouplingData();
10 31
11 /* Adapter: Adjust solver time */ 32 /* Adapter: advance the coupling */
12 adapter.adjustSolverTimeStep(); 33 adapter.advance();
13 34
14 /* Adapter: Write checkpoint */ 35 /* Adapter: Read checkpoint */
15 if(adapter.isWriteCheckptRequired()) 36 if(adapter.isReadCheckptRequired())
16 adapter.writeCheckpoint(); 37 adapter.readCheckpoint();
17 38
18 runTime++; 39 if(adapter.isCouplTimeStepComplete())
19 40 runTime.write();
20 /* Adapter: Receive coupling data */ 41
21 adapter.readCouplingData(); 42 }
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN2 10 Before: Working and validated prototypes
Image from desertcart.ae.
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN2 11 Before: Working and validated prototypes
Image from desertcart.ae.
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN2 11 Now: A user-friendly, plug-and-play adapter
The human-like figure is a property of ikea.com.
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN2 12 Part IIb: a new, official adapter
+
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN2 13 Several advantages: • No source code changes • Load at runtime • (mostly) Solver agnostic However: • Still ready-to-run only for CHT • but...
Making this a function object
Several challenges: • No changes in the source allowed − Cannot use variables directly − Ask the objects’ registry • One adapter for all the solvers and problem types − Some parameters are not available
• Only one call to execute() at the end − We may need to reload a checkpoint at the last timestep... − Set the endTime to GREAT and exit when ready.
• Collaboration with other function objects − At the end, call any other end() methods explicitly.
• Error handling − read() degrades errors to warnings − Catch them and throw them in execute
• One adapter for all the OpenFOAM flavors and versions? − E.g. boundaryField() and boundaryFieldRef() − E.g. missing adjustTimeStep() − How to distribute? Branches/Tags? Preprocessor ifdef?
• ...
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN2 14 However: • Still ready-to-run only for CHT • but...
Making this a function object
Several challenges: Several advantages: • No changes in the source allowed • No source code changes − Cannot use variables directly • Load at runtime − Ask the objects’ registry • (mostly) Solver agnostic • One adapter for all the solvers and problem types − Some parameters are not available
• Only one call to execute() at the end − We may need to reload a checkpoint at the last timestep... − Set the endTime to GREAT and exit when ready.
• Collaboration with other function objects − At the end, call any other end() methods explicitly.
• Error handling − read() degrades errors to warnings − Catch them and throw them in execute
• One adapter for all the OpenFOAM flavors and versions? − E.g. boundaryField() and boundaryFieldRef() − E.g. missing adjustTimeStep() − How to distribute? Branches/Tags? Preprocessor ifdef?
• ...
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN2 14 Making this a function object
Several challenges: Several advantages: • No changes in the source allowed • No source code changes − Cannot use variables directly • Load at runtime − Ask the objects’ registry • (mostly) Solver agnostic • One adapter for all the solvers and problem types However: − Some parameters are not available • Still ready-to-run only for CHT • Only one call to execute() at the end • but... − We may need to reload a checkpoint at the last timestep... − Set the endTime to GREAT and exit when ready.
• Collaboration with other function objects − At the end, call any other end() methods explicitly.
• Error handling − read() degrades errors to warnings − Catch them and throw them in execute
• One adapter for all the OpenFOAM flavors and versions? − E.g. boundaryField() and boundaryFieldRef() − E.g. missing adjustTimeStep() − How to distribute? Branches/Tags? Preprocessor ifdef?
• ...
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN2 14 An extensible adapter
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN2 15 OK! I want to use it!
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN2 16 Properties for incompressible solvers:
1 // constant/transportProperties
2 rho rho [1-300000]1;
3 Cp Cp [02-2-1000] 5000;
Properties for basic solvers:
1 // constant/transportProperties
2 k k [11-3-1000] 100;
OpenFOAM configuration
1 // system/controlDict
2 functions
3 {
4 preCICE_Adapter
5 {
6 type preciceAdapterFunctionObject;
7 libs ("libpreciceAdapterFunctionObject.so");
8 }
9 }
Set the appropriate boundary condition types:
1 // 0/T
2 interface
3 {
4 type fixedValue;
5 value uniform 300;
6 }
7
8 // other types: fixedGradient, mixed
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN2 17 OpenFOAM configuration
1 // system/controlDict
2 functions
3 {
4 preCICE_Adapter
5 {
6 type preciceAdapterFunctionObject;
7 libs ("libpreciceAdapterFunctionObject.so");
8 }
9 }
Set the appropriate boundary condition types: Properties for incompressible solvers:
1 // 0/T 1 // constant/transportProperties
2 interface 2 rho rho [1-300000]1;
3 { 3 Cp Cp [02-2-1000] 5000;
4 type fixedValue; Properties for basic solvers: 5 value uniform 300;
6 } 1 // constant/transportProperties 7 2 k k [11-3-1000] 100; 8 // other types: fixedGradient, mixed
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN2 17 preCICE & adapter configuration
libprecice adapter
Solver A Solver B
YAML YAML XML
Adapter A Config Adapter B Config preCICE Config
To run the simulation, just execute the solvers as usual.
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN2 18 Tutorials
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN2 19 Example: Biomedical applications
• FSI simulation of an aortic bloodflow • Joint work with the Barcelona Supercomputing Center
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN2 20 Example: Multi-fluid coupling
Linearized Euler Equations
• Besides FSI, many other possible Euler applications of preCICE Equations • Simulation of a subsonic jet w w o o • Navier-Stokes f t Explicit, parallel coupling between three fluid f u n
I Equations solvers O • Joint work with the University of Siegen Euler Equations
Linearized Euler Equations
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN2 21 Does it work with “chocolate” OpenFOAM?
Known to work with: The OpenFOAM Foundation: 4.0 – dev ESI - OpenCFD: v1706
Currently does not work with: The OpenFOAM Foundation: ≤ 3.0 ESI - OpenCFD: ≤ v1606+ foam-extend: any version
Coming soon: • Support for older versions • Code improvements and tests Contribute on GitHub! • Fluid-Structure Interaction Module
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN2 22 Questions?
Website: precice.org Mailing list: precice.org/resources Source/Wiki: github.com/precice My e-mail: [email protected]
Homework: • Follow a tutorial • Join our mailing list • Star on GitHub • Send us feedback • Ask me for stickers
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN2 23 Questions?
Website: precice.org Mailing list: precice.org/resources Source/Wiki: github.com/precice My e-mail: [email protected]
Homework: • Follow a tutorial • Join our mailing list • Star on GitHub • Send us feedback • Ask me for stickers
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN2 23 Additional slide: Time step sizes
Time step sizes and checkpointing
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN2 24 Additional slide: Function Objects
Callbacks in OpenFOAM function objects
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN2 25 Additional slide: The CHT Module
The Conjugate Heat Transfer module
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN2 26 Additional slide: preCICE scaling
Strong scaling of a coupled simulation with two Ateles participants and 5.7 · 107dofs
Gerasimos Chourdakis (TUM) | Couple OpenFOAM with any other solver using preCICE | Feb 21, 2018 | GOFUN2 27