xx Poisson

Poisson

Erik Schnetter <schnetter@gmail.com>

November 25, 2014

Abstract

This is an example thorn describing how to use the TATPETSc interface to PETSc. It solves the Poisson equation for a spherical charge distribution on a uniform grid.

1 Introduction

PETSc is a well-known library for solving elliptic equations. TATPETSc is a Cactus thorn that provides a wrapper for calling PETSc to solve elliptic equations on uniform grids. (TATPETSc currently supports neither mesh refinement nor multi-block systems.) TATPETSc can solve both linear and non-linear systems.

2 Physical System Here we solve the Poisson equation

where the right hand side is given by

for the charge and the radius , with . We use Dirichlet boundary conditions .

3 Numerical Implementation PETSc supports a large number of options to choose solvers. Here we use PETSc’s default settings.

4 Using This Thorn In the example parameter file, we set the parameter TATPETSc::options to select the following PETSc options:

-snes_atolx1e-8: set absolute tolerance for residual

-snes_stolx1e-8: set relative tolerance for residual

-snes_monitor: output progress information at each iteration of the non-linear solver

-ksp_monitor: output progress information at each iteration of the linear (Krylov subspace) solver 4.1 Examples

The solution (the potential ) is stored in the grid function potential, the residual (a measure for the error) in the grid function residual.

5 Parameters

11charge 10Scope: privatex01  REAL

11Description: Charge of uniformly charged sphere

11 Range 10  x01  Default: 1.0

11*:*  10

11

11options10Scope: privatex01  STRING

11Description: Options for the solver

11 Range 10 x01 Default: (none)
11.*  10no restriction

11

11radius 10Scope: privatex01  REAL

11Description: Radius of uniformly charged sphere

11 Range 10  x01  Default: 1.0

110:*  10

11

11solver 10Scope: privatex01  STRING

11Description: Name of TATelliptic solver that should be used

11 Range 10 x01 Default: TATJacobi
11.*  10must be an activated TATelliptic solver

11

6 Interfaces

General Implements: poisson

Inherits: boundary grid

Grid Variables

6.0.1 PRIVATE GROUPS

11x Group Names x10x Variable Names xx01 Details x11x
11  potential  10  x01  compact110
11                 10  phi  x01 description11Potential for elliptic equation
11                 10  x01 dimensions113
11                 10  x01 distribution11DEFAULT
11                 10  x01 group type11GF
11                 10  x01 timelevels111
11                 10  x01variable type11REAL
11  residual  10  x01  compact110
11                 10  res  x01 description11Residual for elliptic equation
11                 10  x01 dimensions113
11                 10  x01 distribution11DEFAULT
11                 10  x01 group type11GF
11                 10  x01 timelevels111
11                 10  x01variable type11REAL

11

Uses header: carpet.h TATelliptic.h

7 Schedule This section lists all the variables which are assigned storage by thorn CactusExamples/Poisson. Storage can either last for the duration of the run (Always means that if this thorn is activated storage will be assigned, Conditional means that if this thorn is activated storage will be assigned for the duration of the run if some condition is met), or can be turned on for the duration of a schedule function.

Storage x

11Always:  11x
11potential residual11x

11x  11x

Scheduled Functions

CCTKxINITIAL x poissonxprepare x set up initial guess for initial data x

11x11Language:11c
11 x 11Type: 11function
11 x 11Writes: 11poisson::phi(everywhere)

11

CCTKxPOSTINITIAL x poissonxsolve x calculate uniform charge initial data x

11x11Language:11c
11 x 11Reads: 11poisson::phi(everywhere)
11 x 11x  11grid::coordinates(interior)
11 x 11Type: 11function
11 x 11Writes: 11poisson::res(interior)

11

x poissonxboundaries x apply boundary conditions to initial data x

11x11Type:11group

11

Poissonxboundaries x poissonxboundariesxselect x select boundary conditions for initial data x

11x11Language:11c
11 x 11Options: 11level
11 x 11Sync:  11potential
11 x 11Type: 11function

11

Poissonxboundaries x applybcs x apply boundary conditions to initial data x

11x11After:11poissonxboundariesxselect
11 x 11Type:11group

Aliased Functions x

11Alias Name: xxxxxxx11Function Name:
11ApplyBCs  11Poissonxboundariesxapply