18.2-petsc-example

18.2-petsc-example - Introduction Example problem Code...

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

View Full Document Right Arrow Icon
Introduction Example problem Code implementation Learn more An example to demonstrate how to use PETSc (only very basic usage) Wenjun Deng January 2010
Background image of page 1

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

View Full DocumentRight Arrow Icon
Introduction Example problem Code implementation Learn more Contents 1 Introduction 2 Example problem 3 Code implementation 4 Learn more
Background image of page 2
Introduction Example problem Code implementation Learn more Contents 1 Introduction 2 Example problem 3 Code implementation 4 Learn more
Background image of page 3

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

View Full DocumentRight Arrow Icon
Introduction Example problem Code implementation Learn more Introduction PETSc is a very powerful toolbox for manipulating linear algebraic objects (vectors, matrixes, etc.) using parallel computing. PETSc wraps the parallel operations (MPI) very well, so the programmer can ALMOST only focus on the mathematical objects. For example, you can create a matrix A and a vector b and tell PETSc to solve the linear equation Au = b , with ALMOST no need to care about how A and b are stored among nodes and how to parallelize the solving algorithm. ALMOST: when it comes to efficiency, you want to care a little about the parallel structure and algorithm.
Background image of page 4
Introduction Example problem Code implementation Learn more Contents 1 Introduction 2 Example problem 3 Code implementation 4 Learn more
Background image of page 5

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

View Full DocumentRight Arrow Icon
Introduction Example problem Code implementation Learn more Example problem 2D Poisson’s equation -∇ 2 f ( x,y ) = sin( πx ) sin( πy ) in a square domain 0 x 1, 0 y 1. Boundary conditions: f (0 ,y ) = f (1 ,y ) = f ( x, 0) = f ( x, 1) = 0 Not hard to guess the analytic solution: f ( x,y ) = 1 2 π 2 sin( πx ) sin( πy )
Background image of page 6
Introduction Example problem Code implementation Learn more Use finite difference method to solve the problem Function f ( x,y ) can be discretized as f i,j and written as a vector: u = ( f 0 , 0 ,f 0 , 1 ,f 0 , 2 ··· ,f 0 ,n - 1 ,f 1 , 0 ,f 1 , 1 , ··· ,f n - 1 ,n - 1 ) T Similarly, h 2 sin( πx ) sin( πy ) can be discretized and written as a vector b . ( h is the grid size) Five-point Laplacian approximation: ( -∇ 2 f ) i,j 4 f i,j - f i - 1 ,j - f i +1 ,j - f i,j - 1 - f i,j +1 h 2 h 2 ( -∇ 2 f ) can be written as u multiplied by a matrix A , then the Poisson’s equation becomes a set of linear equations: Au = b
Background image of page 7

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

View Full DocumentRight Arrow Icon
Introduction Example problem Code implementation Learn more
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 22

18.2-petsc-example - Introduction Example problem Code...

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

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