SFEMaNS  version 4.1 (work in progress) Reference documentation for SFEMaNS
Test 28 Hydrodynamic Simulation of the VKS Experiment

### Introduction

In this example, we check the correctness behavior of SFEMaNS for a hydrodynamic problem with a moving solid obstacle involving Dirichlet boundary conditions. The set up consists of a fluid driven by contra rotative impellers in a cylinder container. In the litterature, it is referred as Von Karman Sodium. Here we study the case with impellers called TM73, we refer to the paper Direct numerical simulation of the axial dipolar dynamo in the Von Karman Sodium experiment (Nore et al. 2016) for more information on this set up.

We note this test does not involve manufactured solutions and consists of checking four quantities, like the $$\bL^2$$ norm of the velocity, are the same than the values of reference.

We solve the Navier-Stokes equations:

\begin{align*} \partial_t\bu+\left(\ROT\bu\right)\CROSS\bu - \frac{1}{\Re}\LAP \bu +\GRAD p &=\bef &\text{ in } \Omega_\text{fluid}, \\ \bu & = r \omega \be_\theta &\text{ in } \Omega_\text{imp_bot}, \\ \bu & = -r \omega \be_\theta &\text{ in } \Omega_\text{imp_top}, \\ \DIV \bu &= 0, &\\ \bu_{|\Gamma} &= \bu_{\text{bdy}} ,& \\ \bu_{|t=0} &= \bu_0, &\\ p_{|t=0} &= p_0,& \end{align*}

in the domain $$\Omega= \{ (r,\theta,z) \in {R}^3 : (r,\theta,z) \in [0,1] \times [0,2\pi) \times [-1,1]\}$$. This domain is the union of a fluid domain $$\Omega_\text{fluid}$$ and two solid domains, $$\Omega_\text{imp_top}$$ and $$\Omega_\text{imp_bot}$$ that represent the impellers. These subdomains depend of the time as the impellers are contra rotating with an angular velocity $$\omega$$. We also define $$\Gamma= \partial \Omega$$. The data are the source term $$\bef$$, an angular velocity $$\omega$$, the penalty function $$\chi$$, the boundary data $$\bu_{\text{bdy}}$$, the initial datas $$\bu_0$$ and $$p_0$$. The parameter $$\Re$$ is the kinetic Reynolds number.

Remark: We note that the velocity field is forced to match the velocity of the impellers in the solid subdomains with a penalty method. This method involves a penalty function $$\chi$$ equal to 1 in $$\Omega_\text{fluid}$$ and zero elsewhere.

### Manufactured solutions

As mentionned earlier this test does not involve manufactured solutions. As a consequence, we do not consider specific source term and only initialize the variables to approximate.

The initial velocity field and pressure are initialized as follows:

\begin{align*} u_r(r,\theta,z,t) &= 0, \\ u_{\theta}(r,\theta,z,t) &= \begin{cases} -r \omega \be_\theta & \text{ in } \Omega_\text{imp_top}, \\ 0 &\text{ in } \Omega_\text{fluid}, \\ r \omega \be_\theta & \text{ in } \Omega_\text{imp_bot}, \end{cases} \\ u_z(r,\theta,z,t) &= 0, \\ p(r,\theta,z,t) &= 0, \end{align*}

The penalty function $$\chi$$ is defined such that it is equal to 1 in the fluid domain $$\Omega_1$$ and $$0$$ elsewhere. We note that we use a smooth penalty function.

The finite element mesh used for this test is named mesh_T28_0_04_04_ext3.FEM and has a mesh size of $$0.04$$ for the P1 approximation. You can generate this mesh with the files in the following directory: ($SFEMaNS_MESH_GEN_DIR)/EXAMPLES/EXAMPLES_MANUFACTURED_SOLUTIONS/mesh_T28_0_04_04_ext3. The following image shows the mesh for P1 finite elements.  Finite element mesh (P1). The following images show a 3D representation of the VKS set up and the shape of the impellers that drive the fluid.  VKS Setting. Impeller TM73. ### Information on the file condlim.f90 The initial conditions, boundary conditions, the forcing term and the penalty function are set in the file condlim_test_28.f90. Here is a description of the subroutines and functions of interest. 1. First we define many numbers at the begining of the module so that every subroutines has access to these real numbers. These numbers are used to define the penalty function, meaning the shape of the impellers, or to set the velocity of the impellers. 2. The subroutine init_velocity_pressure initializes the velocity field and the pressure at the time $$-dt$$ and $$0$$ with $$dt$$ being the time step. It is done by using the functions vv_exact and pp_exact as follows: time = 0.d0 DO i= 1, SIZE(list_mode) mode = list_mode(i) DO j = 1, 6 !===velocity un_m1(:,j,i) = vv_exact(j,mesh_f%rr,mode,time-dt) un (:,j,i) = vv_exact(j,mesh_f%rr,mode,time) END DO DO j = 1, 2 !===pressure pn_m2(:) = pp_exact(j,mesh_c%rr,mode,time-2*dt) pn_m1 (:,j,i) = pp_exact(j,mesh_c%rr,mode,time-dt) pn (:,j,i) = pp_exact(j,mesh_c%rr,mode,time) phin_m1(:,j,i) = pn_m1(:,j,i) - pn_m2(:) phin (:,j,i) = Pn (:,j,i) - pn_m1(:,j,i) ENDDO ENDDO 3. 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. 1. First we set the velocity to zero. vv=0.0 2. We define the velocity field depending of the Fourier mode and its TYPE (1 and 2 for the component radial cosine and sine, 3 and 4 for the component azimuthal cosine and sine, 5 and 6 for the component vertical cosine and sine) as follows: IF (type==3 .AND. m==0) THEN DO n = 1, SIZE(rr,2) r= rr(1,n) z= rr(2,n) ! Are we in the Bottom propeller? IF ( if_bottom_prop .AND. r <disk_radius .AND. z < top_of_blade_bot ) then vv(n)=solid_vel*r END IF !are we in the top Propeller? IF ( if_top_prop .AND. r <disk_radius .AND. z > bot_of_blade_top) then vv(n)=-solid_vel*r END IF END DO END IF RETURN where solid_vel is the angular velocity of the impeller and is set to 1. 4. The function pp_exact contains the analytical pressure. It is used to initialize the pressure to zero. vv=0.d0 RETURN 5. The function source_in_NS_momentum computes the source term $$\bef$$ of the Navier-Stokes equations. It is set to zero. 6. The function penal_in_real_space defines the penalty function $$\chi$$ in the real space (depending of the node in the meridian plan and its angle n). It is done by calling the function smooth_penal_in_real_space as follows: vv=smooth_penal_in_real_space(mesh,rr_gauss,angles,nb_angles,nb,ne,time) This function is equal to zero in the impeller and 1 elsewhere. It is defined with the use other functions such as smooth_bottom_propeller or smooth_top_propeller. 7. The function imposed_velocity_by_penalty is used to set a non zero velocity in the impellers. 1. First we set the empellers velocity to zero. vv=0.d0 2. We do a loop on the node of the mesh and define the radial and vertical coordinates r, z. DO n = 1, SIZE(rr,2) r= rr(1,n) z= rr(2,n) 3. If the node considered has a vertical coordinate smaller than $$-0.5$$, it is in the bottom impeller of angular velocity solid_vel. IF (z<-0.5d0) THEN vv(n,3) = solid_vel*rr(1,n) 4. Else the node is in the top impeller of angular velocity -solid_vel. ELSE vv(n,3) = -solid_vel*rr(1,n) ENDIF END DO RETURN All the other subroutines present in the file condlim_test_28.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_28 and can be found in the directory ($SFEMaNS_DIR)/MHD_DATA_TEST_CONV_PETSC.

1. We use a formatted mesh by setting:
===Is mesh file formatted (true/false)?
.t.
2. The path and the name of the mesh are specified with the two following lines:
===Directory and name of mesh file
'.' mesh_T28_0_04_04_ext3.FEM
where '.' refers to the directory where the data file is, meaning ($SFEMaNS_DIR)/MHD_DATA_TEST_CONV_PETSC. 3. We use one processor in the meridian section. It means the finite element mesh is not subdivised. ===Number of processors in meridian section 1 4. We solve the problem for $$64$$ Fourier modes. ===Number of Fourier modes 64 5. We use $$8$$ processors in Fourier space. ===Number of processors in Fourier space 8 It means that each processors is solving the problem for $$64/8=8$$ Fourier modes. 6. We do not select specific Fourier modes to solve. ===Select Fourier modes? (true/false) .f. As a consequence, the code approximates the problem on the first $$64$$ Fourier modes. 7. We approximate the Navier-Stokes equations by setting: ===Problem type: (nst, mxw, mhd, fhd) 'nst' 8. 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$$. 9. We use a time step of $$0.01$$ and solve the problem over $$10$$ time iterations. ===Time step and number of time iterations 0.01 10 !628 iterations = one turn since omega=1.0 As the angular speed is set to one, we note it would require 628 time steps to have a full rotation of the impellers. 10. 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 7 ===List of subdomains for Navier-Stokes mesh 1 2 3 4 5 6 7 11. 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? 3 ===List of boundary pieces for full Dirichlet BCs on velocity 2 10 4 12. We set the kinetic Reynolds number $$\Re$$. ===Reynolds number 20.d0 13. We use a penalty function function to take into account the presence of impellers. ===Use penalty in NS domain (true/false)? .t. 14. The solid is moving (contra rotating impellers), so we need to set: ===Use nonzero velocity in solids (true/false)? .t. 15. We give information on how to solve the matrix associated to the time marching of the velocity. 1. ===Maximum number of iterations for velocity solver 100 2. ===Relative tolerance for velocity solver 1.d-6 ===Absolute tolerance for velocity solver 1.d-10 3. ===Solver type for velocity (FGMRES, CG, ...) GMRES ===Preconditionner type for velocity solver (HYPRE, JACOBI, MUMPS...) MUMPS 16. We give information on how to solve the matrix associated to the time marching of the pressure. 1. ===Maximum number of iterations for pressure solver 100 2. ===Relative tolerance for pressure solver 1.d-6 ===Absolute tolerance for pressure solver 1.d-10 3. ===Solver type for pressure (FGMRES, CG, ...) GMRES ===Preconditionner type for pressure solver (HYPRE, JACOBI, MUMPS...) MUMPS 17. We give information on how to solve the mass matrix. 1. ===Maximum number of iterations for mass matrix solver 100 2. ===Relative tolerance for mass matrix solver 1.d-6 ===Absolute tolerance for mass matrix solver 1.d-10 3. ===Solver type for mass matrix (FGMRES, CG, ...) CG ===Preconditionner type for mass matrix solver (HYPRE, JACOBI, MUMPS...) MUMPS 18. 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 the following directory: ($SFEMaNS_DIR)/MHD_DATA_TEST_CONV_PETSC.

To check the well behavior of the code, we compute four quantities:

1. The L2 norm of the divergence of the velocity field.
2. The L2 norm of the divergence of the velocity field divided by the H1 norm of the veloctity field.
3. The L2 norm of the velocity field.
4. The H1 norm of the pressure.

These quantities are computed at the final time $$t=0.1$$. They are compared to reference values to attest of the correctness of the code.

These values of reference are in the last lines of the file debug_data_test_28 in the directory (\$SFEMaNS_DIR)/MHD_DATA_TEST_CONV_PETSC. They are equal to:

============================================
mesh_T28_0_04_04_ext3.FEM
===Reference results
8.59642068557655986E-002 !L2-norm on div of u
2.32688350427632945E-002 !L2-norm of div of u err/norm
0.47840385650238321 !L2-norm of u
1.7279248727889553 !H1-norm of p

To conclude this test, we show the profile of the approximated pressure and velocity magnitude at the final time. These figures are done in the plane $$y=0$$ which is the union of the half plane $$\theta=0$$ and $$\theta=\pi$$.

 Pressure in the plane plane y=0. Velocity magnitude in the plane plane y=0.