39 lines
1.5 KiB
HTML
39 lines
1.5 KiB
HTML
<a href="ex4.c.html"><h2>Example 4</h2></a>
|
|
<p>
|
|
This example differs from the previous structured example
|
|
(Example 3) in that a more sophisticated stencil and
|
|
boundary conditions are implemented. The method illustrated
|
|
here to implement the boundary conditions is much more general
|
|
than that in the previous example. Also symmetric storage is
|
|
utilized when applicable.
|
|
<p>
|
|
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. Note that the struct
|
|
interface assumes a cell-centered grid, and, therefore, the
|
|
nodes are not shared.
|
|
<p>
|
|
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
|
|
<p><center>A = [A_ii A_ib; A_bi A_bb],</center>
|
|
<p>
|
|
then we solve
|
|
<p><center>[A_ii 0; 0 I] [x_i ; x_b] = [b_i - A_ib u_0; u_0].</center>
|
|
<p>
|
|
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.
|
|
<p>
|
|
A number of solvers are available. More information can be
|
|
found in the Solvers and Preconditioners chapter of the
|
|
User's Manual.
|
|
<p>
|
|
We recommend viewing examples 1, 2, and 3 before viewing this
|
|
example.
|