AMS 595 Second C++ Assignment
In the second graded assignment, you will create two C++ programs as described below.
You should write these programs on your own: do not copy from any source. Your source code
les should include thorough documentation. Equal points will be given to each program.
Create a brief README le that summarizes your experimentation with these programs.
Background
Elliptic partial di erential equations (PDEs) are used to model many natural phenomena,
e.g., heat dissipation in a metal sheet, and many physical systems. They are used in aircraft
design as well as in weather prediction, (weather, ow over wing, turbulence, etc.). Many
numerical strategies to solve a speci c PDE are iterative methods based on nite di erencing,
whereby a mesh is generated to represent the physical domain, the points on the mesh or
grid are initialized, usually with an approximate solution, and then repeatedly updated to
obtain an increasingly accurate solution. This process may be repeated for a xed number
of iterations or until the solution has reached the desired level of accuracy.
The solution to the Poisson’s equation describes the steady state of a system. For exam-
ple, the stabilized temperature distribution on a steel rod, with one end holding in your hand
and the other end in the air, is the solution of a certain Poisson’s equation. To approximate
the solution numerically, one need to solve a huge diagonally dominant linear system. A
common way to solve such a system is using iterative methods like the Jacobi iterations or
the Gauss-Seidel method.
Each iteration stores the newly calculated values in another array, and swaps the arrays
at the end of the iteration. These iterations continue until the di erence each iteration is
below a certain threshold. The RMS, or root mean square is used to calculate this di erence:
r1
n(x
21 + x22 + + x2n)
Your Work
You will use two di erent iterative methods to model the ow of heat in a square (2-D grid).
You may choose the methods mentioned above, or another method that you are familiar with.
In each case, your program should ask the user to input the maximum number of iterations
to be performed, and output the RMS of the di erence between the last two iterations. If no
input is speci ed, the programs should test for convergence by comparing the results of two
consecutive iterations: if the di erence is extremely small, then the solution is reached and
no more iterations need be performed. Your program should output the result, the value
used to test for convergence, the number of iterations performed, and the execution time.
You should create a rectilinear grid to represent the square area and initialize one side
of it with the value 1 to represent a heat source, and the rest of the grid with value 0. In
1
order to keep track of the di erences between iterations without making an additional copy
of the matrix, the di erences will need to be summed each time an element in the matrix is
updated, and accumulated in a separate array or variable.
In a separate le, brie y describe some experiments you performed using these methods,
di erent levels of accuracy (i.e. di erent values used for the convergence test) and the time
taken.
Please submit both versions of your programs to the TA by midnight on Sunday, Decem-