hw2 - CS 240A Assignment 2 Solving Poisson’s Equation by...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 240A Assignment 2: Solving Poisson’s Equation by Conjugate Gradients Assigned April 6, 2011 Due by 11:59 pm Monday, April 18 This assignment is to write a parallel program to implement the congugate gradient algorithm (CG for short), which solves a system of linear equations Ax = b for any symmetric, positive definite matrix A ; and to use your CG solver to solve a specific linear system called the “model problem”, which is a discretization of Poisson’s equation on a two-dimensional region. We have supplied sequential Matlab versions of all of this code; your job will be to write a parallel MPI-based version. The main part of this will be to write three subroutines that do the bulk of the numerical work: matvec (which multiplies the model-problem matrix by a vector), ddot (which computes the inner product of two vectors), and daxpy (which scales and adds together two vectors). You should do this assignment in a team of two students, coming from different departments. Exceptions must be approved in advance, and will be allowed only if we run out of candidates. Feel free to advertise on the course email list for a partner! After your team turns in its solution, your team will be paired randomly with another team: the two teams will exchange solutions, and you will write a review of the other team’s solution and a comparison between them. There’s a lot of background for this problem in the slides from the April 6 lecture. 1 The model problem Poisson’s equation arises in many applications, including fluid dynamics, electromagnetics, and heat flow. Here we’ll use it to compute the steady-state temperature in a square region whose boundary temperatures are known. The region is the unit square, 0 ≤ x ≤ 1 and 0 ≤ y ≤ 1. The temperature t ( x, y ) satisfies Poisson’s equation, ∂ 2 t ( x, y ) ∂x 2 + ∂ 2 t ( x, y ) ∂y 2 = 0 , (1) in the interior of the region, and the boundary the values of t ( x, y ) are given as input. To solve this problem numerically, we make two approximations: First, instead of asking for the answer at every point in the unit square region (an infinite problem!), we discretize the problem by filling the interior of the region with a finite, square grid of points. We ’ll use k points in both the x and y directions, for n = k 2 points in all. (The choice of k will affect both how accurate and how expensive our solution will be.) We space the points evenly inside the unit square, so the distance between adjacent points is 1 / ( k + 1). Then we number the grid points from 1 to n , row by row, like this example with k = 6: 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 The point in row r and column s of the grid has index i = ( r- 1) k + s ; for example, the grid point in row 2, column 4 has index i = (2- 1) · 6 + 4 = 10. Now we will just try to compute the the n 2 temperatures t ( i ) for each grid point i , instead of t ( x, y ) for all real x and...
View Full Document

{[ snackBarMessage ]}

Page1 / 7

hw2 - CS 240A Assignment 2 Solving Poisson’s Equation by...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online