1710 FVDiscr Example

igor-konshin edited this page Mar 21, 2017 · 6 revisions

Parallel Finite Volume Discretization

The code for this example is located in Examples/FVDiscr


This example uses simple two-point FVM scheme to solve Poisson's equation in unit cube domain. The following classes are used: Mesh, Partitioner, Solver.


This examples is used to solve the problem div(K grad U) = f with Dirichlet boundary conditions, where K is unit tensor and the right-hand side f is computed from the exact solution: U = sin(PI·x)·sin(PI·y)·sin(PI·z).

This example may run in both serial and parallel modes with NP processes.

The code loads the mesh for unit cube domain. If INMOST is built with USE_PARTITIONER=ON and input mesh is a serial mesh, then the Inner_RCM partitioner is used to partition the mesh.

One layer of ghost cells is created and exchanged. The simplest two-point FVM scheme is used to assemble local matrices. Using ghost cells effectively links local matrices in global matrix. Two-point FVM scheme is only valid when cell faces are orthogonal to segments connecting centers of neighboring cells.

Optionally the code saves the generated matrix and right-hand side in user provided files. The distributed matrix is solved using INNER_ILU2 solver. The solution is compared with known exact solution and C and L₂ norms are computed. The result mesh is saved either in result.vtk, or result.pvtk depending on number of NP.


Usage: ./FVDiscr mesh_file [A.mtx b.rhs]
  • First parameter is the mesh file.
  • Two optional parameters – output file names for generated matrix and right-hand side.

Running example

If you compiled INMOST with USE_PARTITIONER=OFF you should provide the prepartitioned mesh, otherwise you can provide either serial mesh, or prepartitioned mesh.

You can generate meshes using GridGen generator. The following line uses /tmp/grid-32-32-32.pvtk mesh from GridGen example.

$ cd Examples/FVDiscr
$ mpirun -np 4 ./FVDiscr /tmp/grid-32-32-32.pvtk /tmp/A.mtx /tmp/b.rhs                                                                   
Processors: 4
Load(MPI_File): 0.274381
Assign id: 0.00758195
Exchange ghost: 0.0783911
Matrix assemble: 0.242945
Save matrix "/tmp/A.mtx" and RHS "/tmp/b.rhs": 0.0802951
Solve system: 0.2625042e-07 | 1e-05
err_C  = 0.000801001
err_L2 = 0.000283771
Compute true residual: 0.184962
Retrieve data: 0.000687122
Exchange phi: 0.000224113
Save "result.pvtk": 0.137682

If you have ParaView installed, you can open the result mesh file:

$ paraview --data=result.pvtk

You can view the following tags:

  • Solution – the solution to the problem
  • K – tensor K (constant equal to 1 in this example)
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.