Coupling with preCICE by Gerasimos Chourdakis

From OpenFOAM Wiki
Jump to navigation Jump to search

Main idea

Imagine having to study a very complex multi-physics problem (such as CHT, FSI, or something very different). Now imagine having experts established in each of the involved regions, but none of them can alone study the problem accurately and efficiently in its entirety. What if you could help the experts work as a team?

If your experts are simulation software, then you can make them collaborate with preCICE. Each software package calls the preCICE library, which provides flexible and efficient methods for communication, spatial and temporal interpolation, and equation coupling.

preCICE overview

OpenFOAM is one of the most common simulation software packages you can couple, in this case just by using a function object at runtime, without any code changes. The list of software you can couple OpenFOAM to includes CalculiX, FEniCS, deal.II, DUNE, Nutils, code_aster, SU2, and more, while you can also couple your own in-house code with a few additional lines of code, without changing its code structure or your workflows. Of course, you can even couple different OpenFOAM solvers, even from different OpenFOAM versions (including solid solvers from solids4foam).

In this tutorial, we will first couple two OpenFOAM solvers (buoyantPimpleFoam and laplacianFoam) for conjugate heat transfer. Then, we will couple OpenFOAM to deal.II for fluid-structure interaction. This tutorial closely follows the respective training session from the 16th OpenFOAM Workshop: Flexible and efficient multiphysics simulations with the coupling library preCICE and the preCICE tutorials.

Everything presented here is free/open-source software. The preCICE library and ecosystem are developed openly on GitHub.

Preparations

Due to the nature of partitioned multi-physics simulations, we will need to also install multiple software components. We will need of course OpenFOAM, preCICE, and the OpenFOAM adapter for preCICE. For the FSI example, we will also need deal.II and the deal.II adapter.

It's a lot to read, and that's completely understandable. If you have limited time, the Quickstart may actually be helpful (which is another tutorial by itself).

CHT tutorial: Flow over a heated plate

In this example, we will simulate the coolling of a very simple hot plate. Our experts will be buoyantPimpleFoam for the flow, and laplacianFoam for the heat conduction on the solid. Why couple two OpenFOAM solvers instead of solving both regions in chtMultiRegionFoam? Well, laplacianFoam is only a convenient starting example. Instead of laplacianFoam, you can also readily choose among FEniCS, Nutils, Dune-Fem, CalculiX, or code_aster for the same example.

CHT case setup

But let's not duplicate the detailed instructions you can read (and improve) directly on the preCICE website.

FSI tutorial: Flow in a channel with a perpendicular flap

In this example, we will simulate a bending rod (flap) in a channel flow. This is a relatively easy and fast fluid-structure interaction case. Our experts will be pimpleFoam for the flow, and deal.II for the structure. Instead of deal.II, you can also choose among CalculiX, FEniCS, DUNE, solids4Foam, or even solidDisplacementFoam.

In case you prefer, many people have also coupled OpenFOAM to CalculiX for FSI. See also the community tutorials playlist "FSI for vascular flows using OpenFOAM, preCICE, and CalculiX". Many related conference talks and application videos are also available on YouTube.

FSI case setup

Follow the detailed instructions on the preCICE website.

Further reading

For a starting point into the preCICE library, read (and please cite) the latest reference paper titled preCICE v2: A sustainable and user-friendly coupling library.

Specifically on coupling OpenFOAM to other solvers via preCICE, read (and please cite) the OpenFOAM-preCICE paper in the OpenFOAM Journal.

For details into each feature, check out the preCICE literature guide.