# Numerical Coupling between a FEM Code and the FVM Code OpenFOAM Using the MED Library
## 4 Numerical Results
### Buoyant-Driven Cavity  
In the following section, a first numerical application is presented to show the simulation results of a code-coupling procedure between volume fields, taking reference data from the literature as a benchmark. The simulation setting is depicted in Figure 3, where a square cavity is considered as the numerical domain for the resolution of Navier-Stokes and temperature equations. In this case, we can consider a Newtonian and incompressible fluid for which a two-dimensional setting has been investigated. In particular, these equations are coupled through the buoyancy term. Therefore, considering the velocity \(\mathbf{u}\), the pressure \(p\), and the temperature \(T\), we have  
\[\
abla\cdot\mathbf{u}=0\,, \tag{1}\] \[\frac{\partial\mathbf{u}}{\partial t}+\mathbf{u}\cdot\
abla\mathbf{u}=\frac{ p}{\rho}+\
u\Delta\mathbf{u}+\mathbf{g}\beta(T-T_{0})\,,\] \[\frac{\partial T}{\partial t}+\mathbf{u}\cdot\
abla T=\alpha\Delta T +Q\,,\]  
where \(\
u\) is the kinematic viscosity, \(\rho\) the density, \(\beta\) the coefficient of thermal expansion, \(\alpha\) the thermal diffusivity, \(T_{0}\) the reference temperature, and \(Q\) the volumetric thermal source. We recall that \(\
abla\cdot\) represents the divergence operator and \(\
abla\) is the gradient, while \(\Delta\) is the Laplacian. For all the presented tests, a laminar behavior of the flow is considered.  
Regarding the boundary condition, we impose no-slip boundary conditions for the velocity field at each boundary edge. For the energy equation, both Dirichlet and Neumann boundary conditions are used. In particular, we impose the temperature on two opposite edges, creating a hot and a cold wall, while on the remaining edges, an insulation condition is imposed, according to Figure 3. Furthermore, the volumetric thermal source \(Q\) is set to zero for every numerical simulation.  
Figure 3: Geometry of the buoyant cavity problem with boundary conditions for the temperature field.  
As we know from the literature, the form of the solution to this problem depends on the nondimensional Rayleigh number that is defined as \(Ra=g\rho\beta L^{3}(T_{H}-T_{C})/(\
u a)\), where \(L\) is the reference length of the domain. Referring to Figure 3, we have \(L=l\). Moreover, the reference temperature \(T_{0}\) is set to the mean value between \(T_{H}\) and \(T_{C}\) for every specific simulation. The numerical tests were performed for different \(Ra\) numbers, ranging from \(10^{3}\) up to \(10^{6}\) and compared with reference data. Specifically, this problem has been described in several works [23; 24; 25; 26; 27].  
Regarding the numerical approach, four different approaches are presented and analyzed. Two simulations are performed by solving the system of Equations (1) considering a monolithic solution with the FEMuS code (\(F\)) and OpenFOAM (\(OF\)) taken as reference. The other two cases use the code-coupling technique: in the first case (\(c_{1}\)), the temperature is solved in FEMuS and the velocity in OpenFOAM, and vice versa in the second case (\(c_{2}\)). In the two latter procedures, we recall that the coupling between the codes takes place through two terms in the equations: the buoyancy term, which requires the temperature field in the momentum equation, and the advection term in the energy equation, which is computed via the velocity field coming from the momentum equation. This is a necessary condition for the cases \(c_{1}\) and \(c_{2}\) to satisfy the problem described in (1). In particular, the field transfer is performed considering the volumetric value of the specific field, so for each cell of the target mesh, the field is interpolated from the source mesh by using the MED structures described in the previous section. The entire volumetric field is transferred between the two codes, adopting the same discretization for the domain, even if the FEM codes consider biquadratic quadrilateral elements as the FVM code uses linear quadrilateral elements.