SFEMaNS  version 4.1 (work in progress)
Reference documentation for SFEMaNS
 All Classes Files Functions Variables Groups Pages
The function source_in_NS_momentum

It is used to define the source term \(\textbf{f}\) of the Navier-Stokes equations. We refer to the section Approximation of the Navier-Stokes equations for more information on the formulation of the Navier-Stokes equations in SFEMaNS.

This function defines the source term for one given Fourier mode, one given component (radial cosine, radial sine, azimuthal cosine, azimuthal sine, vertical cosine or vertical sine) on all the nodes of the finite element mesh. We denote by vv_mesh the finite element mesh used to approximate the velocity field.

Inputs and outputs

The inputs of this function are the following:

  1. TYPE is the component of the source term that we compute (radial cosine, radial sine, etc.). It is an integer between one and six.
  2. rr is a real valued tabular that contains two columns with dimensions (2,vv_mesh%np). The tabular rr(1,:) contains the radial cylindrical coordinate of all the nodes of the finite element mesh vv_mesh. Respectively, rr(2,:) contains the vertical coordinates of these nodes.
  3. mode is the Fourier mode considered. It is an integer.
  4. i is the label that the processor associates to the Fourier mode considered. It is an integer.
  5. time is the time at which the source term is computed. It is a real number.
  6. opt_density is the density. This input is optional.
  7. opt_tempn is the temperature. This input is optional.

The output of this function is a real valued tabular vv of dimension SIZE(rr,2).


  1. We note that opt_density and opt_tempn are optional because solving the Navier-Stokes equations does not imply to solve the temperature or the level set equations.
  2. The density is available when the following parameter is set to true in the data:
    ===Is there a level set?
  3. The temperature is available when the following parameter is set to true in the data file:
    ===Is there a temperature field?


Here is an exemple where the source term is equal to \(-\rho \textbf{e}_z\) with \(\rho\) being the density and \(\textbf{e}_z\) being the unit vector in the vertical direction.

IF (PRESENT(opt_density)) THEN
vv = -opt_density(:,1,i)
vv = -opt_density(:,2,i)
vv = 0.d0
CALL error_petsc('problem in source_in_NS_momentum: set level set to true in data to have a density')


  1. We check that the variable opt_density is present. If not, it means the data file is not correctly set: it does not use a level set and a variable density. As a consequence, the code is stopped with the function error_petsc.
  2. The source term only depends of the vertical direction (TYPE 5 and 6).
  3. When we consider the vertical cosine part of the source term, it involve the cosine part of the density. Same goes when considering sine part.
  4. The vertical sine part of the source term is set to zero when the Fourier mode considered is zero. It is due to the fact that \(\sin(0\theta)=0\) for all \(\theta\in[0,2\pi]\).

We refer to the sections Examples with manufactured solutions and Examples on physical problems for more examples.