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

11 charge 10 Scope: private01  REAL

11 Description: Charge of uniformly charged sphere

11 Range 10              01  Default: 1.0

11 *:*  10

11

11 options 10 Scope: private01  STRING

11 Description: Options for the solver

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

11

11 radius 10 Scope: private01  REAL

11 Description: Radius of uniformly charged sphere

11 Range 10              01  Default: 1.0

11 0:*  10

11

11 solver 10 Scope: private01  STRING

11 Description: Name of TATelliptic solver that should be used

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

11

6 Interfaces

General Implements: poisson

Inherits: boundary grid

Grid Variables

6.0.1 PRIVATE GROUPS

11 x Group Names x 10 x Variable Names x01 Details x 11 x
11  potential  10                    01  compact 11 0
11                    10  phi  01 description 11 Potential for elliptic equation
11                    10                    01 dimensions 11 3
11                    10                    01 distribution 11 DEFAULT
11                    10                    01 group type 11 GF
11                    10                    01 timelevels 11 1
11                    10                    01 variable type 11 REAL
11  residual  10                    01  compact 11 0
11                    10  res  01 description 11 Residual for elliptic equation
11                    10                    01 dimensions 11 3
11                    10                    01 distribution 11 DEFAULT
11                    10                    01 group type 11 GF
11                    10                    01 timelevels 11 1
11                    10                    01 variable type 11 REAL

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

11 Always:  11 x
11 potential residual 11 x

11 x  11 x

11

Scheduled Functions

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

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

11

CCTKxPOSTINITIAL x poissonxsolve x calculate uniform charge initial data x

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

11

x poissonxboundaries x apply boundary conditions to initial data x

11 x 11 Type: 11 group

11

Poissonxboundaries x poissonxboundariesxselect x select boundary conditions for initial data x

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

11

Poissonxboundaries x applybcs x apply boundary conditions to initial data x

11 x 11 After: 11 poissonxboundariesxselect
11 x 11 Type: 11 group

11

Aliased Functions x

11 Alias Name: xxxxxxx 11 Function Name:
11 ApplyBCs  11 Poissonxboundariesxapply