Skip to content

2D Poisson Equation Solver. Discretized using the Finite Difference Method & Solved by Parallelising the Jacobi Iterative Method via the OpenMP API.

License

Notifications You must be signed in to change notification settings

MRLintern/2D_Poisson_Equation_OpenMP

Repository files navigation

2D Poisson's Equation


Introduction: Poisson's Equation


  • Poisson's Equation is a Partial Differential Equation (PDE) that describes how a Scalar Field (like Electric Potential, Temperature, or Gravitational Potential) varies in Space due to a Source Term.
  • The mathematical form of this PDE is:
    • del * (del u) = f(x, y).
    • del * del is the Laplace Operator.
    • u is the unknown Scalar Field.
    • f(x, y) is the Source Term in 2D Space; note: 3D case: f(x, y, z).
  • What does this equation tell us?
  • Poisson’s Equation tells you how sources (e.g., charge, mass, heat) generate or influence a Potential Field.
  • In terms of Fluid Dynamics, u represents the Pressure Field inside an Incompressible Flow and f represents Negative Divergence of Velocity.
  • What this means is How Velocity Divergence relates to Pressure.
  • Note: this project/software doesn't look any physical scenario.

Poisson's Equation and OpenMP


  • OpenMP helps solve Poisson’s equation more efficiently by Parallelizing the computational workload, which is often the most time-consuming part in numerical methods.
  • In methods like Finite Difference or Finite Element, you Discretize the Domain into a Grid and iteratively solve for u(x,y) using an algorithm like Jacobi, Gauss-Seidel, or SOR.
  • For a 2D grid of size N×N, each iteration involves updating every interior grid point using neighboring values.
  • This is computationally expensive, especially for:
    • Fine grids (large N).
    • Many iterations (to converge).

How OpenMP Helps

1. Parallelizes Grid Updates
  • Each point in the grid update is independent (especially in Jacobi iteration), so OpenMP can safely split the workload among multiple threads.
  • This means multiple points are computed simultaneously, reducing total computation time.
2. Speeds Up Iterations
  • Since each iteration involves updating the entire grid, OpenMP allows multiple CPU cores to work in parallel, reducing the time per iteration. This is especially effective for high-resolution grids.
3. Improves Scalability
  • OpenMP is scalable across many cores, so performance improves with hardware — making it a simple yet powerful way to scale up simulations.

Requirements


  • Compiler: gcc 13.1.0; needs to support OpenMP.
  • OS: Ubuntu 20.04.
  • A `text editor for any changes.
  • Make.

Getting and Using the Software


  • $ git clone git@github.com:MRLintern/2D_Poisson_Equation_OpenMP.git
  • $ cd 2D_Poisson_Equation_OpenMP
  • If you want to generate the results and produce the plot yourself:
  • $ make clean
  • Unit Testing:
  • $ make test
  • All test cases (should) pass. Now create the executable:
  • $ make
  • $ ./main
  • Plot the Results:
  • You don't need to be in the results directory to create the plot; just stay inside 2D_Poisson_Equation_OpenMP. Note: the plot, solution_and_error_surface.png, will be saved inside results.
  • $ python3 plot_results.py
  • An image will be created and saved in the results directory.

About

2D Poisson Equation Solver. Discretized using the Finite Difference Method & Solved by Parallelising the Jacobi Iterative Method via the OpenMP API.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published