Introduction
In this example, we check the correctness of SFEMaNS for the use of Robin boundary conditions on the temperature. This boundary condition is usefull when the cooling or the heating of a body by convection at the boundaries is considered. A mix of Dirichlet and Robin boundary conditions is used in this test.
The domain of computation is \(\Omega= \{ (r,\theta,z) \in {R}^3 : (r,\theta,z) \in (1/2,1) \times [0,2\pi) \times (0,1)\} \). We enforce Dirichlet BCs on the union of the boundaries \(r=1/2\) and \(z=0\), called \(\Gamma_D\). We enforce Robin BCs on the boundaries \(r=1\), called \(\Gamma_{R,1}\), and \(z=1\), called \(\Gamma_{R,2}\). We call \(\Gamma = \partial \Omega\).
We solve the temperature equations:
\begin{align*} \begin{cases} \rho c\partial_t T + \rho c \bu \cdot \GRAD T - \DIV (\lambda \GRAD T) &= f_T, \\ T_{|\Gamma_D} &= T_\text{bdy} , \\ (- h_1 T - \lambda \GRAD T \SCAL \bn)_{|\Gamma_{R,1}} &= - h_1 T_1 , \\ (- h_2 T - \lambda \GRAD T \SCAL \bn)_{|\Gamma_{R,2}} &= - h_2 T_1 , \\ T_{|t=0} &= T_0, \end{cases} \end{align*}
in the domain \(\Omega\). The parameters \(h_1\), \(h_2\) and \(T_1\) are constants that represent the convection ceofficients and the exterior temperature respectively.
We solve the Navier-Stokes equations:
\begin{align*} \begin{cases} \partial_t\bu+\left(\ROT\bu\right)\CROSS\bu - \frac{1}{\Re}\LAP \bu +\GRAD p &= \bef, \\ \DIV \bu &= 0, \\ \bu_{|\Gamma} &= \bu_{\text{bdy}} , \\ \bu_{|t=0} &= \bu_0, \\ p_{|t=0} &= p_0, \end{cases} \end{align*}
in the domain \(\Omega\).
The data are the source terms \(f_T\) and \(\bef\), the boundary data \(T_1\), \(T_\text{bdy}\) and \(\bu_{\text{bdy}}\), and the initial data \(T_0\), \(\bu_0\) and \(p_0\). The parameters are the density \(\rho\), the heat capacity \(c\), the thermal conductivity \(\lambda\), the convection coefficients \(h_1\) and \(h_2\) and the kinetic Reynolds number \(\Re\).
Manufactured solutions
We approximate the following analytical solution:
\begin{align*} T(r,\theta,z,t) & = \left( \exp \left( - \frac{h_1 r+h_2 z}{\lambda} \right) + (r-1)^2 + (z-1)^2 \right)(1+\cos(\theta))\cos(t) + T_1 , \\ u_r(r,\theta,z,t) &= 0, \\ u_{\theta}(r,\theta,z,t) &= 0, \\ u_z(r,\theta,z,t) &= 0, \\ p(r,\theta,z,t) &= 0, \end{align*}
where the temperature is chosen to satisfy the Robin BCs.
The source terms \(f_T, \bef\) and the boundary data \(T_\text{bdy}, \bu_{\text{bdy}}\) are computed accordingly.
Generation of the mesh
The finite element mesh used for this test is named SOLID_FLUID_10.FEM and has a mesh size of \(0.1\) for the P1 approximation. You can generate this mesh with the files in the following directory: ($SFEMaNS_MESH_GEN_DIR)/EXAMPLES/EXAMPLES_MANUFACTURED_SOLUTIONS/SOLID_FLUID_10. The following image shows the mesh for P1 finite elements.
Finite element mesh (P1).
|
Only the right part of the mesh is used for the computation in this test: \( r \ge 1/2 \).
Information on the file condlim.f90
The initial conditions, boundary conditions and the forcing terms \(\textbf{f}\) in the Navier-Stokes equations and \(f_T\) in the temperature equations are set in the file condlim_test_35.f90. Here is a description of the subroutines and functions of interest.
-
The subroutine
init_velocity_pressure initializes the velocity field and the pressure at the times \(-dt\) and \(0\) with \(dt\) being the time step. This is done by using the functions vv_exact and pp_exact as follows: DO j = 1, 6
!===velocity
END DO
DO j = 1, 2
!===pressure
phin_m1(:,j,i) = pn_m1(:,j,i) - pn_m2(:)
phin (:,j,i) = Pn (:,j,i) - pn_m1(:,j,i)
ENDDO
ENDDO
-
The subroutine
init_temperature initializes the temperature at the times \(-dt\) and \(0\) with \(dt\) the time step. This is done by using the function temperature_exact as follows: DO j = 1, 2
tempn_m1(:,j,i) = temperature_exact(j, mesh%rr, mode,
time-dt)
tempn (:,j,i) = temperature_exact(j, mesh%rr, mode,
time)
ENDDO
ENDDO
-
The function
vv_exact contains the analytical velocity field. It is used to initialize the velocity field and to impose Dirichlet boundary conditions on the velocity field. The velocity is equal to 0 (for every type or mode).
-
The function
pp_exact contains the analytical pressure. It is used to initialize the pressure. The pressure is equal to 0 (for every type or mode).
-
The function
temperature_exact contains the analytical temperature. It is used to initialize the temperature and to impose Dirichlet boundary condition on the temperature.
-
We construct the radial and vertical coordinates r, z.
-
We define the thermal conductivity, the convection coefficients and the exterior temperature.
lambda =
inputs%temperature_diffusivity(1)
h1 =
inputs%convection_coeff(1)
h2 =
inputs%convection_coeff(2)
T1 =
inputs%exterior_temperature(1)
-
We define the temperature depending on its TYPE (1 and 2 for cosine and sine) and on its mode as follows:
x = (h1 * r + h2 *
z) / lambda
IF (TYPE==1) THEN
IF (m==0) THEN
vv = ( exp(-x) + (r - 1d0)**2 * (z - 1d0)**2 ) * cos(t) + T1
ELSE IF (m==1) THEN
vv = ( exp(-x) + (r - 1d0)**2 * (z - 1d0)**2 ) * cos(t)
ELSE
vv = 0d0
END IF
ELSE
vv = 0.d0
END IF
-
The function
source_in_temperature computes the source term \(f_T\) of the temperature equations.
-
We construct the radial and vertical coordinates r, z.
-
We define the volumetric heat capacity (the product \(\rho c\)), the thermal conductivity and the convection coefficients.
c =
inputs%vol_heat_capacity(1)
lambda =
inputs%temperature_diffusivity(1)
h1 =
inputs%convection_coeff(1)
h2 =
inputs%convection_coeff(2)
-
The source term \( f_T = \rho c \partial_t T + \rho c \bu \cdot \GRAD T - \DIV(\lambda\GRAD T) \) is defined in two parts since the velocity is null:
x = (h1 * r + h2 *
z) / lambda
! source = c pdt T - lambda laplacien T
! c pdt T
IF (TYPE==1) THEN
IF ((m==0).OR.(m==1)) THEN
vv = - c * ( exp(-x) + (r - 1d0)**2 * (z - 1d0)**2 ) * sin(t)
ELSE
vv = 0d0
END IF
ELSE
vv = 0d0
END IF
! - lambda laplacien T
IF (TYPE==1) THEN
IF (m==0) THEN
vv = vv - lambda * ( &
1d0/r * ( -h1/lambda * exp(-x) + 2 * (r - 1d0) * (z - 1d0)**2 ) * cos(t) &
+ ( (h1/lambda)**2 * exp(-x) + 2 * (z - 1d0)**2 ) * cos(t) &
+ ( (h2/lambda)**2 * exp(-x) + 2 * (r - 1d0)**2 ) * cos(t) )
ELSE IF (m==1) THEN
vv = vv - lambda * ( &
1d0/r * ( -h1/lambda * exp(-x) + 2 * (r - 1d0) * (z - 1d0)**2 ) * cos(t) &
+ ( (h1/lambda)**2 * exp(-x) + 2 * (z - 1d0)**2 ) * cos(t) &
- 1d0/r**2 * ( exp(-x) + (r - 1d0)**2 * (z - 1d0)**2 ) * cos(t) &
+ ( (h2/lambda)**2 * exp(-x) + 2 * (r - 1d0)**2 ) * cos(t) )
END IF
END IF
-
The function
source_in_NS_momentum computes the source term \(\bef\) of the Navier-Stokes equations. It is null.
All the other subroutines present in the file condlim_test_35.f90 are not used in this test. We refer to the section Fortran file condlim.f90 for a description of all the subroutines of the condlim file.
Setting in the data file
We describe the data file of this test. It is called debug_data_test_35 and can be found in the directory ($SFEMaNS_DIR)/MHD_DATA_TEST_CONV_PETSC.
-
We use a formatted mesh by setting:
===Is mesh file formatted (true/false)?
.t.
-
The path and the name of the mesh are specified with the two following lines:
===Directory and name of mesh file
'.' 'SOLID_FLUID_10.FEM'
where '.' refers to the directory where the data file is, meaning ($SFEMaNS_DIR)/MHD_DATA_TEST_CONV_PETSC.
-
We use \(2\) processors in the meridian section.
===Number of processors in meridian section
2
-
We solved the problem for \(2\) Fourier modes.
===Number of Fourier modes
2
The Fourier modes are not detailed so the first 2 modes \(0,1\) are solved.
-
We use \(2\) processors in Fourier space.
===Number of processors in Fourier space
2
It means that each processors is solving the problem for \(2/2=1\) Fourier modes.
-
We approximate the Navier-Stokes equations by setting:
===Problem type: (nst, mxw, mhd, fhd)
'nst'
-
We do not restart the computations from previous results.
===Restart on velocity (true/false)
.f.
It means the computation starts from the time \(t=0\).
-
We use a time step of \(0.01\) and solve the problem over \(100\) time iterations.
===Time step and number of
time iterations
1.d-2 100
-
We set the number of domains and their label, see the files associated to the generation of the mesh, where the code approximates the Navier-Stokes equations.
===Number of subdomains in Navier-Stokes mesh
1
===List of subdomains for Navier-Stokes mesh
2
-
We set the number of boundaries with Dirichlet conditions on the velocity field and give their respective labels.
===How many
boundary pieces
for full Dirichlet BCs on velocity?
4
===List of
boundary pieces
for full Dirichlet BCs on velocity
3 5 2 4
-
We set the kinetic Reynolds number \(\Re\).
-
We give information on how to solve the matrix associated to the time marching of the velocity.
-
===Maximum number of iterations
for velocity
solver100
-
===Relative tolerance
for velocity
solver1.d-6
===Absolute tolerance
for velocity
solver1.d-10
-
===Solver type for velocity (FGMRES, CG, ...)
GMRES
===Preconditionner type for velocity
solver (HYPRE, JACOBI, MUMPS...)
MUMPS
-
We give information on how to solve the matrix associated to the time marching of the pressure.
-
===Maximum number of iterations
for pressure
solver100
-
===Relative tolerance
for pressure
solver1.d-6
===Absolute tolerance
for pressure
solver1.d-10
-
===Solver type for pressure (FGMRES, CG, ...)
GMRES
===Preconditionner type for pressure
solver (HYPRE, JACOBI, MUMPS...)
MUMPS
-
We give information on how to solve the mass matrix.
-
===Maximum number of iterations
for mass matrix
solver100
-
===Relative tolerance
for mass matrix
solver1.d-6
===Absolute tolerance
for mass matrix
solver1.d-10
-
===Solver type for mass matrix (FGMRES, CG, ...)
CG
===Preconditionner type for mass matrix
solver (HYPRE, JACOBI, MUMPS...)
MUMPS
-
We solve the temperature equation.
===Is there a temperature field?
.t.
-
We set the number of domains and their label, see the files associated to the generation of the mesh, where the code approximates the temperature equation.
===Number of subdomains in temperature mesh
1
===List of subdomains for temperature mesh
2
-
We set the density \(\rho\), the heat capacity \(c\) and the thermal conductivity \(\lambda\).
===Density (1:nb_dom_temp)
1.d0
===Heat capacity (1:nb_dom_temp)
2.d0
===Thermal conductivity (1:nb_dom_temp)
10.d0
-
We set the number of boundaries with Dirichlet conditions on the velocity and give their respective labels.
===How many
boundary pieces
for Dirichlet BCs on temperature?
2
===List of
boundary pieces
for Dirichlet BCs on temperature
3 4
-
We set the number of boundaries with Robin conditions on the velocity and give their respective labels.
===How many
boundary pieces
for Dirichlet BCs on temperature?
2
===List of
boundary pieces
for Dirichlet BCs on temperature
5 2
-
We set the convection coefficients \(h_1\) and and \(h_2\), and the exterior temperature \(T_1\).
===Convection heat transfert coefficient (1:temperature_nb_robin_sides)
5d0 2d0
===Exterior temperature (1:temperature_nb_robin_sides)
3d0 3d0
-
We give information on how to solve the matrix associated to the time marching of the temperature.
-
===Maximum number of iterations
for temperature
solver100
-
===Relative tolerance
for temperature
solver1.d-6
===Absolute tolerance
for temperature
solver1.d-10
-
===Solver type for temperature (FGMRES, CG, ...)
GMRES
===Preconditionner type for temperature
solver (HYPRE, JACOBI, MUMPS...)
MUMPS
-
To get the total elapse time and the average time in loop minus initialization, we write:
===Verbose timing? (true/false)
.t.
These informations are written in the file lis when you run the shell debug_SFEMaNS_template.
Outputs and value of reference
The outputs of this test are computed with the file post_processing_debug.f90 that can be found in: ($SFEMaNS_DIR)/MHD_DATA_TEST_CONV_PETSC.
To check the well behavior of the code, we compute four quantities:
-
The L2-norm of error on u.
-
The L2-norm of error on p.
-
The L2-norm of error on T divided by L2-norm of T exact.
-
The H1-norm of error on T divided by H1-norm of T exact.
These quantities are computed at the final time \(t=1\). They are compared to reference values to attest of the correct behavior of the code. These values of reference are in the last lines of the file debug_data_test_35 in ($SFEMaNS_DIR)/MHD_DATA_TEST_CONV_PETSC. They are equal to:
============================================
(SOLID_FLUID_10.FEM)
===Reference results
0.000000000000000E+000 L2-norm of error on u
0.000000000000000E+000 L2-norm of error on p
3.017387149621566E-007 L2-norm of error on T / L2-norm of T exact
1.936024637254978E-005 H1-norm of error on T / H1-norm of T exact
To conclude this test, we display the profile of the approximated temperature at the final time. The figure is done in the plane \(y=0\) which is the union of the half plane \(\theta=0\) and \(\theta=\pi\).
Temperature in the plane y=0.
|