Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
1710 FVDiscr Example
Parallel Finite Volume Discretization
The code for this example is located in
This example uses simple two-point FVM scheme to solve Poisson's equation in unit cube domain.
The following classes are used:
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
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
The solution is compared with known exact solution and C and L₂ norms are computed.
The result mesh is saved either in
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.
If you compiled INMOST with
USE_PARTITIONER=OFF you should provide the prepartitioned mesh, otherwise you can provide either serial mesh, or prepartitioned mesh.
$ 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.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)