# Numerical Coupling between a FEM Code and the FVM Code OpenFOAM Using the MED Library
## 5 Conclusions  
In this work, an algorithm for the numerical coupling of a finite volume code (OpenFOAM) and a finite element code (FEMuS) is presented by using an external library (MED). The code coupling relies on volumetric and boundary data exchange over the simulated domain without using external files. The algorithm is suitable for multiphysics simulations where different codes with different fields of application can be coupled based on their specific field features.  
Specifically, we presented two types of data exchange: a volume and a boundary data transfer. The volume coupling considers the volume transfer data in a buoyant-driven cavity problem. The boundary coupling considers a conjugate heat transfer problem between a solid and a fluid. The usage of the two coupling strategies is strictly connected to the engineering and physical problem under examination and does not affect the performance of the coupling. In fact, many engineering applications can be successfully modeled with the coupling methodology described in this paper, leveraging the features and strengths of the standalone codes.  
In the first application, we tested the code coupling through the buoyancy term in the momentum equation, while in the second application, the coupling was performed by considering the thermal boundary condition on the interface between the two regions. For the buoyant cavity application, the coupling was performed in two ways, firstly solving the momentum equation in OpenFOAM and temperature in FEMuS and then switching the equation to solve between the two codes.  
In the first test, we reported the nondimensional velocity field for different \(Ra\) numbers and compared them with the same data taken from the literature. In general, a good agreement can be noticed for the maximum value of the nondimensional velocity components.  
\begin{table}
\begin{tabular}{c c c c c c c} \hline \hline \multirow{2}{*}{\(Ra\)} & \multicolumn{6}{c}{\(t_{1}\)} \\ \cline{2-7}  & \(K_{1}\) & [32] & \(K_{2}\) & [32] & \(K_{3}\) & [32] \\ \hline \(10^{3}\) & 0.332 & 0.335 & 0.898 & 0.890 & 1.08 & 1.08 \\ \(10^{5}\) & c0.412 & c0.412 & c1.897 & c1.907 & c3.269 & 3.162 \\ \hline \multirow{2}{*}{\(Ra\)} & \multicolumn{6}{c}{\(t_{2}\)} \\ \cline{2-7}  & \(K_{1}\) & [32] & \(K_{2}\) & [32] & \(K_{3}\) & [32] \\ \hline \(10^{5}\) & 0.118 & 0.117 & 0.850 & 0.851 & 2.556 & 2.578 \\ \hline \hline \end{tabular}
\end{table}
Table 4: Average Nusselt number with different conductivity ratios \(K\), varying the \(Ra\) number and wall thickness \(t\). A comparison with results from [32] is also reported.  
For the case of \(Ra=10^{6}\), however, a slight difference can be noted when compared with the literature data. However, all strategies, i.e., OpenFOAM standalone, FEMuS standalone, coupling A, and coupling B, produced similar results. In the second test, by increasing the \(Ra\) number, we obtained the classical temperature isolines of a buoyant cavity, where the isolines distribution still followed the conductivity ratio \(K\). This behavior was independent on the thickness of the solid subdomain.  
Future works will investigate the capability of the presented algorithm to exchange additional physics, such as turbulence modeling, with the aim of enhancing the OpenFOAM models with specific thermal turbulence models available in the FEMuS code.  
Methodology, G.B., A.C., F.G., S.M. and L.S.; Validation, G.B., A.C., F.G., S.M. and L.S.; Investigation, G.B., A.C., F.G., S.M. and L.S.; Writing--original draft, G.B., A.C., F.G., S.M. and L.S.; Writing--review & editing, G.B., A.C., F.G., S.M. and L.S. All authors have read and agreed to the published version of the manuscript  
This research received no external funding.  
Not applicable.  
The data presented in this study are available on request from the corresponding author.  
The authors declare no conflicts of interest.