## Poisson

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

$\begin{array}{rcll}\mathrm{\Delta }\Phi \left(x\right)& =& \rho \left(x\right)& \text{(1)}\text{}\text{}\end{array}$

where the right hand side $\rho$ is given by

$\begin{array}{rcll}\rho \left(r\right)& =& \left\{\begin{array}{cc}Q∕V\hfill & r\le R\hfill \\ 0\hfill & r>R\hfill \end{array}& \text{(2)}\text{}\text{}\end{array}$

for the charge $Q$ and the radius $R$, with $V=4\pi {R}^{3}∕3$. We use Dirichlet boundary conditions $\Phi \left(x\right)=0$.

### 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_atol 1e-8: set absolute tolerance for residual

• -snes_stol 1e-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 $\Phi \left(x\right)$) is stored in the grid function potential, the residual (a measure for the error) in the grid function residual.

### 5 Parameters

 charge Scope: private REAL Description: Charge of uniformly charged sphere Range Default: 1.0 *:*

 options Scope: private STRING Description: Options for the solver Range Default: (none) .* no restriction

 radius Scope: private REAL Description: Radius of uniformly charged sphere Range Default: 1.0 0:*

 solver Scope: private STRING Description: Name of TATelliptic solver that should be used Range Default: TATJacobi .* must be an activated TATelliptic solver

### 6 Interfaces

Implements:

poisson

Inherits:

boundary

grid

#### Grid Variables

##### 6.0.1 PRIVATE GROUPS
 Group Names Variable Names Details potential compact 0 phi description Potential for elliptic equation dimensions 3 distribution DEFAULT group type GF timelevels 1 variable type REAL residual compact 0 res description Residual for elliptic equation dimensions 3 distribution DEFAULT group type GF timelevels 1 variable type REAL

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

 Always: potential residual

#### Scheduled Functions

CCTK_INITIAL

poisson_prepare

set up initial guess for initial data

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

CCTK_POSTINITIAL

poisson_solve

calculate uniform charge initial data

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

poisson_boundaries

apply boundary conditions to initial data

 Type: group

Poisson_boundaries

poisson_boundaries_select

select boundary conditions for initial data

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

Poisson_boundaries

applybcs

apply boundary conditions to initial data

 After: poisson_boundaries_select Type: group

#### Aliased Functions

 Alias Name: Function Name: ApplyBCs Poisson_boundaries_apply