Solve laplace equation using Jacobi/Gauss-Seidel method.
The C version contains a sequential and a parallel (using MPI
) version.
C
- bin: build directory
- src
- 2darrays: functions for 2d array handling
- solvers: implementations of Jacobi and Gauss-Seidel solvers
- laplace_seq.c: sequential version
- laplace_mpi.c: parallel version
-
Requirements: MPI (for the parallel version)
-
Compile using the Makefile
cd C make all
-
Run the sequential version using
./bin/laplace_seq METHOD NX NY TOLERANCE
METHOD
: use Jacobi solver if 0, Gauss-Seidel if 1NX
NY
: number of points in the gridTOLERANCE
: target max difference for convergence
Example:
./bin/laplace_seq 0 128 128 1e-6
-
Run the parallel version using
mpirun -np NUMPROC ./bin/laplace_mpi METHOD NX NY TOLERANCE
Command arguments are as above, plus
NUMPROC
: number of processors
Example:
mpirun -np 4 ./bin/laplace_mpi 0 128 128 1e-6
-
The command returns number of iterations and time needed for convergence. The data is in
laplace.dat
and can be plotted using (requires numpy, matplotlib)python ../python/plot.py laplace.dat
The python version contains a sequential and a parallel version (using mpi4py
).
-
Install all requirements (numpy, mpi4py, matplotlib, numba)
cd python pip install -r requirements.txt
-
Run the sequential version using
python laplace_seq.py METHOD NX NY TOLERANCE
METHOD
jacobi_seq
: sequential version of Jacobi solverjacobi_vec
: vectorized version of Jacobi solver using numpy functionsgs_seq
: sequential version of Gauss-Seidel solvergs_vec
: semi-vectorized version of Gauss-Seidel solver
NX
NY
: number of points in the gridTOLERANCE
: target max difference for convergence
Example:
python laplace_seq.py jacobi_vec 128 128 1e-6
-
Run the parallel version using
mpirun -np NUMPROC python laplace_mpi.py METHOD NX NY TOLERANCE
Command arguments are as above, plus
NUMPROC
: number of processors
Example:
mpirun -np 4 python laplace_mpi.py jacobi_vec 128 128 1e-6
-
Run the numba version using
python laplace_numba.py NX NY TOLERANCE
Example:
python laplace_numba.py 128 128 1e-6
-
The command returns number of iterations, time needed for convergence and plots the solution.