This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: MSC321 Homework 5 r r r r r r r r r b b b b- 1 1 2 i- 2 i- 1 i i + 1 i + 2 M M + 1 M + 2 M + 3 Figure 1: Discrete grid with halo/ghost points of depth 2 shown as halo circles numbered in red. The solid circles numbered in black are the computational points where the derivative is desired. The purpose of this exercise is to develop a program to differentiate functions numerically using finite difference formula. The code will be built subroutine by subroutine and validated at each step of the process. The starting point is the module grid.f90 of homework 4 and Set_Grid that was designed to discretize the real line segment [ x min x max ] into M equally sized intervals of size Δ x = x max- x min M (the routine should return the grid size Δ x and the location of the edge points x i , x i = ( i- 1)Δ x + x min , for i = 1 , 2 ,...,M +1). If you have not done so, validate your code by applying to the following input data x min =- 2, x max = 2 and M = 11, and print the edges, one item per line, to a file called grid.dat . One nagging question about finite difference formula on a discrete grid is how to go about evaluating them near the edges of the interval. Referring to figure 1, it is clear that if the derivative is to be evaluated at x 1 using a centered 3-point stencil, at least one ghost point is required, whereas if the stencil is 5 points wide, 2 ghost points are required. The same hold on the other side of the interval, point x M +1 . In order to get around this problem, it is useful to extend the interval on which the function is defined by an amount dictated by the differencing stencil. This extension is sometimes referred to as a halo or ghost points to emphasize that it is not actually part of the solution domain, but is useful to carry out out the actual computations. The ghost points are shown by halo circles and numbered in red in figure 1....
View Full Document
- Fall '08