SFEMaNS
version 4.1 (work in progress)
Reference documentation for SFEMaNS
|
This section describes the fortran file main.f90
. It focuses on the subroutine my_post_processing
that computes the desired outputs. We note that the other subroutines of the file main.f90
should not be modified and are not described here. A template of the file main.f90
is available in the following directory: ($SFEMaNS_DIR)/TEMPLATE
.
Remark: If ARPACK is not installed, the following lines of the file main.f90
have to be commented.
Apart from these lines, we insist on the fact that only the subroutine my_post_processing
should be modified.
This section is splitted into four subsections. First, the structure of the subroutine my_post_processing
is described. Then information on functions that compute classic quantities (like L2 norm, divergence, etc.) are given. The third subsection describes how to generate 2D and 3D visualization files for Paraview. Eventually an example is provided.
The subroutine my_post_processing
is called after each time iterations. We denote by tn
the time after the time iteration n. This subroutine has access to the variables defined at the begining of the file main.f90
. Here is a list of the variables that are meaningfull to compute outputs:
pp_mesh
is the finite element mesh used to approximate the pressure and the level set. vv_mesh
is the finite element mesh used to approximate the velocity field. pn
is the pressure at time tn. un
is the velocity field at time tn. level_set
is the level set at time tn (for multiphase computation). density
is the density at time tn (for multiphase computation). H_mesh
is the finite element mesh used to approximate the magnetic field. phi_mesh
is the finite element mesh used to approximate the scalar potential. Hn
and Bn
are the magnetic fields at time tn. We remind that \(\mu\textbf{H}=\bB\) with \(\mu\) the magnetic permeability. sigma_field
is the list of the electrical conductivity of each domains where the magnetic field is approximated. mu_h_field
is the list of the magnetic permeability of each domains where the magnetic field is approximated. temp_mesh
is the finite element mesh used to approximate the temperature. temperature
is the temperature at time tn. temperature_diffusivity_field
is the list of the temperature diffusivity of each domains where the temperature is approximated. m_max_c
is the number of Fourier modes approximated by each processors. list_mode
is the list of the Fourier mode approximated by the processor. We note that m_max_c=SIZE(list_mode). time
is the time tn. comm_one_d_ns
is the communicator on the Navier-Stokes equations domain. comm_one_d_temp
is the communicator on the temperature equation domain. comm_one_d
is the communicator on the whole domain. It is equal to the Maxwell equations domain if they are approximated. The structure of the subroutine my_post_processing
is the following:
First, the ranks of each processors are defined. It allows to have one processor writing outputs that depends of a specific Fourier mode or region of the finite element mesh. It can be done as follows.
Remarks:
main.f90
, is denoted rank
. It is usefull when writing an output that does not depend of a specific Fourier mode or a specific region (like the total kinetic energy). Remark: The first two parts of the subroutine my_post_processing
don't need to be modified. Only the section verbose/users ouputs and the section for the visualization files requires modifications depending of the outputs desired.
The verbose ouputs are the average computational time per time iterations, the CFL and the divergence of the velocity and magnetic fields. Here are the required information to have these value computed every inputs%freq_en time iterations.
The subroutine my_post_processing
uses the module tn_axi
. It gives acces to four functions that can compute various quantity like L2 norm, H1 norm, scalar product of vectors. Here is a description of these functions where we denote by norm a real number.
dot_product_SF
computes the scalar product of two vectors. It is called as follows: norm_SF
can compute the L2, H1, sH1 norm of a scalar or a vector. It can also computes the L2 norm of the divergence and the curl of a vector. It is called as follows: In addition, the file main.f90
contains two subroutines that compute a drag force for problem with solid obstacle and the level set conservation for multiphase problem. The following gives information on these two subroutines.
The subroutine FORCES_AND_MOMENTS
computes the drag force of a fluid driven by a vertical velocity field in the presence of a solid obstacle.
condlim.f90
. They are only used if the following parameters are set to true in the data file: section
for more information. fort.12
. The subroutine compute_level_set_conservation
computes the relative error on the level set conservation.
fort.97
. The code SFEMaNS can generate 3D and 2D visualization files of real valued scalar function and real valued vector function. These files are generated with the subroutines vtu_3d
and make_vtu_file_2D
. We note that the 2D plots are generated for each Fourier component of the scalar/vector function.
These subroutines generate files with the extension ".vtu" and ".pvd". The "vtu" files are generated every inputs%freq_plot time iterations. We note that one "vtu" file is generated per processor in meridian section. They contains the informations of the variable to visualize at that time of the computation. One file with the extension ".pvd" is also generated. It contains an overview of all the "vtu" file generated. When opening the "pvd" file with the software Paraview, it allows to have access of the visualization of the variable on the whole domain at different times without loading multiple files.
The file main.f90
provided in the TEMPLATE directory of SFEMaNS generates 3D visualization files for the following variable:
It can also generate 2D files of the above variables when uncommenting the following lines:
and the section between the following lines:
The subroutines vtu_3d generates 3D visualization files.
var
is the variable to plot (like un, pn, Hn, etc.). var_mesh
is the name of the mesh where var is defined (vv_mesh, pp_mesh, temp_mesh, H_mesh or phi_mesh). File_name
is the name of the pvd file generated. The name of the vtu files also start with File_name. However they also present information on the subdomain they represent (_S001, _S002, etc.). 'Var'
is a character of three letters. It is used in Paraview when you want to display the value of the variable var
. what
is equal to 'new' or 'old'. If it is 'new', the subroutine generates a pvd file else it only updates the pvd file. opt_it
is an optional integer. It allows to create vtu time every inputs%freq_plot time iterations by completing the name of the vtu files with "_I001", "_I002", etc. The subroutine make_vtu_2D generates 2D visualization files.
comm_one_d_var(1)
is the comunicator associated to the variable var. Only the first dimension is given. It represents communication between subsections of the finite element mesh (the Fourier component is fixed). var_mesh
is the name of the mesh where var is defined (vv_mesh, pp_mesh, temp_mesh, H_mesh or phi_mesh). header
is the name of the pvd file. The name of the vtu files also start with header. However they also present information on the subdomain they represent (_S001, _S002, etc.). var(:,:,i)
is Fourier component of the variable to plot. We note that the integer i
is only the label of the Fourier component, the Fourier mode is equal to list_mode(i). name_of_field
is a character of three letters. It is used in Paraview when you want to display the value of the variable var
. what
is equal to 'new' or 'old'. If it is new, the subroutine generates a pvd file else it only updates the pvd file. opt_it
is an optional integer. It allows to create vtu time every inputs%freq_plot time iterations by completing the name of the vtu files with "_I001", "_I002", etc. We give a description of the subroutine my_post_processing
of the template file main.f90
. This file can be found in the following directory: ($SFEMaNS_DIR)/TEMPLATE. We refer to the section Examples on physical problems
for more examples.
my_post_processing
. vtu_3d
and make_vtu_file_2D
are defined as follows. Remark: If more than 100 Fourier modes are used, a conflict arises between different energy files. Indeed, the L2 norm of the Fourier component i of the velocity is written in the files fort.xxx with xxx=100+i. The same is done for the magnetic field with the files fort.yyy with yyy=200+i. This problem can be overcome by switching 200 to a larger number. One can also defines proper name for the energy outputs file.