In this chapter we consider explicit discretizations of space- and time-derivatives. In such discretizations we can express directly a derivative at one grid point in terms of function values at adjacent grid points (spatial discretizations) or in terms of previous time levels (temporal discretizations). This, in turn, implies that there is no implicit coupling, and thus there is no matrix inversion involved but instead simple daxpy
The material in this chapter is relatively easy to program both on serial as well as on parallel computers. It is appropriate for demonstrating fundamental concepts of discretization as well as primary constructs of the C++ language and of the MPI library. Specifically, we will demonstrate the use of loops, arrays, functions and passing functions to functions. In addition to presenting MPI_Send and MPI_RecvMPI_Sendrecv and MPI_Sendrecv_replace as alternative advanced MPI function calls for parallelizing finite differences discretizations.
- Section 5.1.1: void SO_FirstDeriv_1D(int npts, double dx, double *u, double *u_x) function definition
- Section 5.1.1: void SO_FirstDeriv_1Dper(int npts, double dx, double *u, double *u_x) function definition
- Section 5.1.2: void SO_SecondDeriv_1D(int npts, double dx, double *u, double *u_xx) function definition
- Section 5.1.2: void SO_SecondDeriv_1Dper(int npts, double dx, double *u, double *u_xx) function definition
- Section 5.1.3: void SO_FirstDeriv_1DP(int npts, double dx, double *u, double *u_x, int mynode, int totalnodes) function definition with MPI_Send/MPI_Recv
- Section 5.1.3: void SO_FirstDeriv_1DP(int npts, double dx, double *u, double *u_x, int mynode, int totalnodes) function definition with MPI_Sendrecv_replace
- Section 5.1.5: void FornbergWeights(double xi, double *x, int m, int n, double ***C) function definition
- Section 5.1.7: void CD_SecondDeriv(int npts, double dx, double dy, double **u, double **u_xx_yy) function definition
- Section 5.1.7: void CrossDerivative(int npts, double dx, double dy, double **u, double **u_xy) function definition
- Section 5.2.1: double AdamsBashforth(int order, double u_old, double dt, double *RHS) function definition
- Section 5.2.4: double RungeKutta4(double uold, double time, double dt, double (*rkfunc)(double,double)) function definition
- Section 5.2.4: double RungeKutta(int order, double dt, double uold, double (*rkfunc)(double)) function definition
Go to the file SCchapter5.h for function/class declarations
Go to the file SCchapter5.cpp for function/class definitionsIn 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 5.1.2: Program for testing the non-periodic first and second derivative approximation routines | chapter5c0.cpp |
Section 5.1.2: Program for testing the periodic first and second derivative approximation routines | chapter5c1.cpp |
Section 5.1.3: MPI - Program for testing the non-periodic parallel first and second derivative approximation routines | chapter5c2P.cpp |
Section 5.1.3: MPI - Program for testing the periodic parallel first and second derivative approximation routines | chapter5c3P.cpp |