# The Grid in Octopus

## Introduction

The fundamental element of Octopus is the real space grid, on which all quantities, such as wave functions, densities and potentials are defined.

In general, a grid consists of

• the mesh
• the simulation box

The mesh is based on an regular mesh in D dimensions, which can be distorted using so-called curvilinear coordinates.

The underlying internal structure is a mesh of integer coordinates and the important mapping arrays which

• map the index to the D integer coordinates
• map the integer coordinates to the index.

The grid is constructed in several steps:

1. Generation of a regular mesh filling a rectangular volume enclosing the simulation box.
2. Selecting inner points, enlargement points and ghost points.
3. re-ordering the points and regeneration of the mapping arrays.

The top level data structure, describing a grid is defined in grid/grid.F90:

  type grid_t
! Components are public by default
class(box_t), pointer       :: box
type(mesh_t)                :: mesh
type(derivatives_t)         :: der
class(coordinate_system_t), pointer :: coord_system
type(stencil_t)             :: stencil

type(symmetries_t)          :: symm
end type grid_t