Petsc: Difference between revisions
From charlesreid1
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
Petsc is the Portable Extensible Toolkit for Scientific Computation. It's used for the parallel solution of PDEs and provides parallel linear and nonlinear solvers. Petsc is written in C. | |||
= Installation = | = Installation = | ||
| Line 53: | Line 53: | ||
== Source code == | == Source code == | ||
There are a number of different header files that must be included in any source code that uses | There are a number of different header files that must be included in any source code that uses Petsc objects or functions. These must be included by using: | ||
<code>#include "headerfile.h"</code> | <code>#include "headerfile.h"</code> | ||
| Line 79: | Line 79: | ||
|} | |} | ||
To determine, more specifically, which header file should be included, visit the Petsc documentation page (http://www.mcs.anl.gov/petsc/petsc-as/documentation/index.html), and locate the documentation page for the function or object of interest. The page will indicate which of the header files listed must be included. | |||
A compiler directive can be used to check if Petsc is being used: | |||
<syntaxhighlight lang="cpp"> | |||
#ifdef HAVE_PETSC | |||
#include "petsc.h" | |||
#endif | |||
</syntaxhighlight> | |||
== Petsc Makefiles == | |||
Revision as of 11:20, 29 November 2010
Petsc is the Portable Extensible Toolkit for Scientific Computation. It's used for the parallel solution of PDEs and provides parallel linear and nonlinear solvers. Petsc is written in C.
Installation
Petsc 2.3.3
Petsc 2.3. can be installed using the following configure line. This will require installation of MPI (I suggest LAM MPI).
/path/to/source/of/petsc-2.3.3/config/configure.py \
--prefix=/path/to/petsc-2.3.3 \
--with-matlab=false \
--with-x=false \
--with-shared=0 \
--with-mpi-dir=/path/to/mpi \
PETSC_DIR=/path/to/source/of/petsc-2.3.3To make this a debug build, add --with-debugging=1 to the configure line.
The build process consists of:
- run the configure wrapper
- turn on lam with lamboot (or whatever MPI you're using)
- make all
- make install
- make test (this script should pass all tests OK)
Petsc 3.0.0
Petsc 3.0.0 can be installed using the configure line:
/path/to/source/of/petsc-3.0.0/config/configure.py \
--prefix=/path/to/petsc-3.0.0 \
--with-matlab=false \
--with-x=false \
--with-shared=0 \
--with-mpi-dir=/path/to/mpi \
PETSC_DIR=/path/to/source/of/petsc-3.0.0The build process is similar to the above:
- run the configure wrapper
- turn on lam with lamboot (or whatever MPI you're using)
- make all
- make install
- make test (this script should pass all tests OK)
Building with Petsc
Source code
There are a number of different header files that must be included in any source code that uses Petsc objects or functions. These must be included by using:
#include "headerfile.h"
Depending on the functionality used, different header files must be used.
| Header file | Function |
|---|---|
| petsc.h | generic header file, should be included unless another header file would be more applicable |
| petscvec.h | vector structure and functions |
| petscmat.h | matrix structure and functions |
| petscksp.h | functions solving linear systems using Krylov subspace methods |
| petscpc.h | preconditioner structure and functions |
To determine, more specifically, which header file should be included, visit the Petsc documentation page (http://www.mcs.anl.gov/petsc/petsc-as/documentation/index.html), and locate the documentation page for the function or object of interest. The page will indicate which of the header files listed must be included.
A compiler directive can be used to check if Petsc is being used:
#ifdef HAVE_PETSC
#include "petsc.h"
#endif