Matrix generation in solving the Stokes equation by FEM




In solving the Stokes equation, one has to consider the solution of linear system under a linear constraint condition. Here, the code is prepared for the matrix generation.



  • DEMO

About this code

This code creates the matrices in solving the Stokes equation over 3D domain.

See JSIAM2020_NS.pdf for an introduction of the problem.


This project does not provide the matrices needed for the a priori error estimation.

Xuefeng LIU, 2020/08/25 Updated: 2022/07/15

About the structure

There are four folders existing. In each folder, the setting file is prepared for a mesh with different size. But since the matrices will be huge, the matrix is not ready yet.

  • Case_2020_08_25_Cube_N_4 (The matrix will be about 0.05G)
  • Case_2020_08_25_Cube_N_8 (The matrix will be about 0.5G)
  • Case_2020_08_25_Cube_N_16 (The matrix will be about 1.8G)
  • Case_2020_08_25_Cube_N_32 (The matrix will be about 10G)

There is also a bin folder, which contains the commands to create matrix and solve the equation.

How to create matrix


  • FEniCS package (http://www.fenicsproject.org)
  • MATLAB or Octave (The create_matrix.sh use Octave as default. You can customize this as MATLAB.)

To create matrix for each folder, enter the bin folder and run create_matrix.sh:

cd ./bin/
chmod 755 *
./create_matrix.sh ../Case_2020_08_25_Cube_N_4/

Calculate the approximate solution

If the solution is needed to check the result, run get_solution.sh, which applies the Lagrange method to solve the equation.

cd ./bin/
./get_solution.sh ../Case_2020_08_25_Cube_N_4/

About the directory

Folders or files beginning with a dot are not displayed by default.

Virtual Machine Setting


You are starting the virtual machine as a visitor to current project. As a visitor, you can change files in the booted virtual machine, but the changed files will be aborted when the server is shut down.

(Please login first to start the virtual machine.)

About Machine Type

The machine with type as "n1-standard-1" has 1 CPU Core and 4GB memory. The Google app compute engine provides a detailed guide of the machine type. For more detailed information, please refer to More detail.
If you need a high-spec machine type, please contact the site manager.