next up previous
Next: Sequential program Up: Short example application programs Previous: Parallel program (user-supplied code)

2D Poisson solver

In this example, the goal is to solve the 2D Poisson problem:

displaymath693

with Dirichlet boundary condition

displaymath694

using Jacobi iteration; i.e., by discretizing the problem domain and applying the following operation to all interior points until convergence is reached:

displaymath695

(This example is based on the discussion of the Poisson problem in [3]).

A sequential program for this computation is straightforward. It maintains two copies of variable u, one for the current iteration (uk) and one for the next iteration (ukp1). At each iteration, it computes the values of ukp1 based on the values of uk. Observe that the boundary points are handled differently -- they maintain a constant value. Every NCHECK steps, the maximum of tex2html_wrap_inline701 is computed to check for convergence.

An equivalent parallel program using the mesh archetype is not much more complicated:

Observe that the code executed by the host and grid processes has the same high-level structure -- both execute the main loop, for example, including the convergence test. This ensures that proper synchronization is maintained.




next up previous
Next: Sequential program Up: Short example application programs Previous: Parallel program (user-supplied code)

Berna L Massingill
Mon Jun 8 19:35:58 PDT 1998