Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Boundary Conditions

Chris White edited this page Nov 18, 2017 · 34 revisions

Input File

The boundary condition flags must be specified in the input file.

<mesh>
ix1_bc     = user          # inner-X1 boundary flag
ox1_bc     = user          # outer-X1 boundary flag
ix2_bc     = outflow       # inner-X2 boundary flag
ox2_bc     = outflow       # outer-X2 boundary flag
ix3_bc     = periodic      # inner-X3 boundary flag
ox3_bc     = periodic      # outer-X3 boundary flag

The following flags are available:

  • outflow : outflowing (zero-gradient) boundary condition
  • reflecting : reflecting boundary condition
  • periodic : periodic boundary condition
  • polar : geometric boundary condition at the pole, available only for the x2-direction in spherical-polar and similar coordinates (see below)
  • user : user-defined boundary condition

For cylindrical- and spherical-like coordinates one often has the azimuthal angle run from 0 to 2π with periodic boundaries. In addition, spherical-like coordinates often have the polar angle run from 0 to π with polar boundaries. See the next section for restrictions on polar boundary conditions.

Polar Boundary Conditions

While Athena++ supports having a reflecting wall or even outflow conditions along the polar axes in spherical-like coordinates, it also supports physically connecting the domain across the axes, allowing fluid to flow from one side to the other with no artificial boundary. This is done by specifying "polar" as the boundary condition for the polar angle. The following restrictions affect this mode:

  • The polar angle must extend to exactly 0 if connecting across the inner (North) pole, and to exactly π (3.141592653589793) if connecting across the outer (South) pole.
  • The azimuthal angle must extend from 0 to 2π (6.283185307179586), and it must have both inner and outer boundaries be periodic, if any polar boundary is used.
  • There must be an even number of cells in the azimuthal direction.
  • The number of MeshBlocks in the azimuthal direction must be either 1 or an even number.
  • All MeshBlocks surrounding a given pole at the same radius must be at the same level of refinement.

The last condition is not currently checked by the code. Polar boundaries work with static mesh refinement, but the user must make sure the refinement scheme does not violate the same-level requirement. Currently adaptive mesh refinement does not protect against the grid evolving to an invalid refinement state.

User-Defined Boundary Conditions

In order to use the user-defined boundary conditions, they must be enrolled in Mesh::InitUserMeshData in the problem generator file.

First, the boundary condition function must be defined. This function has a certain prototype:

void MyBoundary_ix1(MeshBlock *pmb, Coordinates *pco, AthenaArray<Real> &prim, FaceField &b,
                    Real time, Real dt, int is, int ie, int js, int je, int ks, int ke);

And then enroll it:

  EnrollUserBoundaryFunction(INNER_X1, MyBoundary_ix1);

In Athena++, the boundary conditions are applied on the primitive variables and the face-centered magnetic fields. The conservative variables and cell-centered magnetic fields are automatically calculated.

Here is the list of the loop limits for the boundary cells that should be filled in each direction (for the second-order scheme).

Primitives and Transverse B-fields i-lower i-upper j-lower j-upper k-lower k-upper
ix1 is-2 is-1 js je ks ke
ox1 ie+1 ie+2 js je ks ke
ix2 is ie js-2 js-1 ks ke
ox2 is ie je+1 je+2 ks ke
ix3 is ie js je ks-2 ks-1
ox3 is ie js je ke+1 ke+2
Normal B-fields i-lower i-upper j-lower j-upper k-lower k-upper
ix1 is-2 is-1 js je ks ke
ox1 ie+2 ie+3 js je ks ke
ix2 is ie js-2 js-1 ks ke
ox2 is ie je+2 je+3 ks ke
ix3 is ie js je ks-2 ks-1
ox3 is ie js je ke+2 ke+3

For details, see src/bvals/outflow.cpp (or reflect.cpp) and the Programmer Guide. Note that the time and dt parameters are intended for calculating time-dependent boundary conditions.

Clone this wiki locally