Parallel Scientific Computing in C++ and MPI

Chapter 4 Overview



Book Chapter Introduction

In this chapter we apply the approximation theory we presented in chapter 3 to find solutions of linear and nonlinear equations and to perform integration of general functions.  Both subjects are classical, but they serve as basic tools in scientific computing operations and in solving systems of ordinary and partial differential equations.  With regards to root finding, we consider both scalar as well as systems of nonlinear equations.  We present different versions of the Newton-Raphson method, the steepest descent method, and the conjugate gradient method; we will revisit the latter in chapter 9.  With regards to numerical integration we present some basic quadrature approaches, but we also consider advanced quadrature rules with singular integrands or in unbounded domains.

On the programming side, we first introduce the concept of passing a function to a function; in the previous chapter we were passing variables.  This allows an easy implementation of recursion, which is so often encountered in scientific computing. We offer several C++ examples from root finding and numerical integration applications that make use of recursion, and show an effective use of classes and overloaded operators. We also address parallel programming with emphasis on domain decomposition, specifically the concept of reduction operations.  We introduce the MPI commands MPI_Reduce and MPI_Allreduce for accomplishing reduction operations among a collection of processes.


SCchapter4 Introduction and Chapter 4 Driver Programs

    Within the text, there are several places where the software suite is referenced.  In some cases the code is explicitly placed within the text, and at other times within the text we merely alert you that the software is available on this CD.  As you read through Chapter 4, you will find that the following function/classes were discussed.


   The declarations and definitions of these functions/classes can be found in the following files:

Go to the file SCchapter4.h for function/class declarations
Go to the file SCchapter4.cpp for function/class definitions
    In the case that an entire program (meaning that a main() function is provided) is presented in the text, we classify this as a driver program.  Unlike the functions/classes above, driver programs are complete C++ programs which can be compiled and executed.  As you read through the book, you will see that driver programs are often times created by using functions/classes which are in the SCchapter files.  We denote driver programs which are explicitly given in the text of the book in red.  In some chapters, we present very few driver programs explicitly in the text, however we provide some example driver programs which demonstrate how to use the functions/classes with in SCchapter files.  Such driver programs are denoted in black.

 
Section 4.1.4: Newton-Raphson root finding with function passing chapter4c0.cpp
Section 4.1.7: Conjugate Gradient example program chapter4c1.cpp
Section 4.2.1: Example program using the Midpoint, Trapezoidal, and Simpson's rules chapter4c2.cpp
Section 4.2.1: Example program which passes a function to the Trapezoidal Rule function chapter4c3.cpp
Section 4.2.2: Example program for computing the zeros and weights for Legendre, Hermite, and Laguerre quadrature chapter4c4.cpp
Section 4.3: MPI - Program demonstrating the use of MPI_Reduce chapter4c5P.cpp