Parallel Finite Volume Discretization
The code for this example is located in examples/FVDiscr
Brief
This example uses simple two-point FVM scheme to solve Poisson's equation in unit cube domain.
Description
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.
Arguments
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.
GridGen/tmp/grid-32-32-32.pvtk
GridGen example
$ cd examples/FVDiscr
$ mpirun -np 4 ./FVDiscr /tmp/grid-32-32-32.pvtk /tmp/A.mtx /tmp/b.rhs
./FVDiscr
Processors: 4
Load(MPI_File): 0.34929
Assign id: 0.00495315
Exchange ghost: 0.0186219
Matrix assemble: 0.232133
Save matrix "/tmp/A.mtx" and RHS "/tmp/b.rhs": 0.368458
Solve system: 0.1323542e-06 | 1e-05
err_C = 0.00237783
err_L2 = 0.000736251
Compute true residual: 0.561696
Retrieve data: 0.000573874
Exchange phi: 5.00679e-06
Save "result.pvtk": 0.150515
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)