In this post, you'll find the code that I have written for the numerical solution of the 2D heat equation. This is the sequential code, of course. By the way, sequential is the opposite of parallel, just in case you didn't know about it. There should be no confusion between sequential programming as all programming languages are sequential, i.e. the code is executed one line at a time.
To make things easy for newcomers, I have not used any extra header files to place the structure definitions as well as the function prototypes. Good programming practice, however, requries that you use header files to include function definitions, header files, and other stuff.
You will find two files over here. The first one, contains only the c code. Although the file extension is cpp, the code is in c. Using a C++ compiler will be perfect in this case.
The second is a rar archive and includes the visual studio solution files for those who wish to use visual studio C++ express. You can download it here. Simply extract the rar archive and open the ".sln" file.
The minimum that is expected from you is to read the whole code and understand before pressing the build or run buttons. I will most likely upload another version that has detailed comments on how things are done.
Table of Contents:
- Introducing the Heat Equation
- Discretization of the Heat Equation
- Stability Analysis and the Courant-Friedrichs-Lewy Criterion
- Programming the Heat Equation in C using Visual Studio
- MPICH2 and Visual Studio
- Parallel Computing in a Nutshell
- Measuring Parallel Performance
- Essential Ingredients of Message Passing
- MPI Warmup
- Parallelizing the Heat Equation