This example uses the sstruct interface to solve the same problem as was solved in Example 4 with the struct interface. Therefore, there is only one part and one variable.
This code solves the convection-reaction-diffusion problem div (-K grad u + B u) + C u = F in the unit square with boundary condition u = U0. The domain is split into N x N processor grid. Thus, the given number of processors should be a perfect square. Each processor has a n x n grid, with nodes connected by a 5-point stencil. We use cell-centered variables, and, therefore, the nodes are not shared.
To incorporate the boundary conditions, we do the following: Let x_i and x_b be the interior and boundary parts of the solution vector x. If we split the matrix A as
then we solve
Note that this differs from the previous example in that we are actually solving for the boundary conditions (so they may not be exact as in ex3, where we only solved for the interior). This approach is useful for more general types of b.c.
As in the previous example (Example 6), we use a structured solver. A number of structured solvers are available. More information can be found in the Solvers and Preconditioners chapter of the User's Manual.
We recommend viewing Examples 6 before viewing this example.