Functions | Variables

particles/bvals_particle.c File Reference

Sets boundary conditions for particles. More...

Go to the source code of this file.

Functions

static void realloc_sendbuf ()
 Reallocate memory to send buffer.
static void realloc_recvbuf ()
 Reallocate memory to receive buffer.
static void update_particle_status (Grid *pG)
 Update the status of the particles after applying boundary conditions.
static void reflect_ix1_particle (Grid *pG)
 REFLECTING boundary conditions, Inner x1 boundary (ibc_x1=1).
static void reflect_ox1_particle (Grid *pG)
 REFLECTING boundary conditions, Outer x1 boundary (ibc_x1=1).
static void reflect_ix2_particle (Grid *pG)
 REFLECTING boundary conditions, Inner x2 boundary (ibc_x2=1).
static void reflect_ox2_particle (Grid *pG)
 REFLECTING boundary conditions, Outer x2 boundary (ibc_x2=1).
static void reflect_ix3_particle (Grid *pG)
 REFLECTING boundary conditions, Inner x3 boundary (ibc_x3=1).
static void reflect_ox3_particle (Grid *pG)
 REFLECTING boundary conditions, Outer x3 boundary (ibc_x3=1).
static void outflow_particle (Grid *pG)
 OUTFLOW boundary conditions.
static void periodic_ix1_particle (Grid *pG)
 PERIODIC boundary conditions, Inner x1 boundary (ibc_x1=4).
static void periodic_ox1_particle (Grid *pG)
 PERIODIC boundary conditions, Outer x1 boundary (ibc_x1=4).
static void periodic_ix2_particle (Grid *pG)
 PERIODIC boundary conditions, Inner x2 boundary (ibc_x2=4).
static void periodic_ox2_particle (Grid *pG)
 PERIODIC boundary conditions, Outer x2 boundary (ibc_x2=4).
static void periodic_ix3_particle (Grid *pG)
 PERIODIC boundary conditions, Inner x3 boundary (ibc_x3=4).
static void periodic_ox3_particle (Grid *pG)
 PERIODIC boundary conditions, Outer x3 boundary (ibc_x3=4).
static long packing_ix1_particle (Grid *pG, int nlayer)
 Packing the particle inside the inner x1 boundary.
static long packing_ox1_particle (Grid *pG, int nlayer)
 Packing the particle inside the outer x1 boundary.
static long packing_ix2_particle (Grid *pG, int nlayer)
 Packing the particle inside the inner x2 boundary.
static long packing_ox2_particle (Grid *pG, int nlayer)
 Packing the particle inside the outer x2 boundary.
static long packing_ix3_particle (Grid *pG, int nlayer)
 Packing the particle inside the inner x3 boundary.
static long packing_ox3_particle (Grid *pG, int nlayer)
 Packing the particle inside the outer x3 boundary.
static void packing_one_particle (Grain *cur, long n, short pos)
 Subroutine for packing one particle to send buffer.
static void shift_packed_particle (double *buf, long n, int index, double shift)
 shift the coordinate/velocity of the packed particles by a constant amount
static void unpack_particle (Grid *pG, double *buf, long n)
 Unpack received particle Input: pG: grid; buf: received buffer n: number of particle in the buffer Output: pG: grid with new particle added.
static void shearingbox_ix1_particle (Grid *pG, Domain *pD, long numpar)
 Shearing box boundary condition, Inner x1 boundary (ibc_x1=4).
static void shearingbox_ox1_particle (Grid *pG, Domain *pD, long numpar)
 Shearing box boundary condition, Outer x1 boundary (obc_x1=4).
static long packing_ix1_particle_shear (Grid *pG, int reg, long numpar)
 Packing the particle inside the inner x1 boundary for shearing box.
static long packing_ox1_particle_shear (Grid *pG, int reg, long numpar)
 Packing the particle outside the outer x1 boundary for shearing box.
static long packing_particle_fargo (Grid *pG, Real yl, Real yu)
 Packing the particle for FARGO.
static int gridshift (Real shift)
 Get the number of shift of grid in the y direction.
void set_bvals_particle (Grid *pG, Domain *pD)
 Calls appropriate functions to set particle BCs.
void advect_particles (Grid *pG, Domain *pD)
 Advect particles by qshear*Omega_0*x1*dt for the FARGO algorithm.
void set_bvals_particle_init (Grid *pG, Domain *pD)
 Sets function pointers for physical boundaries during initialization, allocates memory for send/receive buffers with MPI.
void set_bvals_particle_fun (enum Direction dir, VBCFun_t prob_bc)
 Sets function pointers for user-defined BCs in problem file.
void set_bvals_particle_destruct (Grid *pG, Domain *pD)
 Finalize boundary condition.

Variables

static double * send_buf = NULL
static double * recv_buf = NULL
static long NBUF
static long send_bufsize
static long recv_bufsize
static int nbc
static int my_iproc
static int my_jproc
static int my_kproc
static Real x1min
static Real x1max
static Real x2min
static Real x2max
static Real x3min
static Real x3max
static Real Lx1
static Real Lx2
static Real Lx3
static int NShuffle
static VBCFun_t apply_ix1 = NULL
static VBCFun_t apply_ox1 = NULL
static VBCFun_t apply_ix2 = NULL
static VBCFun_t apply_ox2 = NULL
static VBCFun_t apply_ix3 = NULL
static VBCFun_t apply_ox3 = NULL

Detailed Description

Sets boundary conditions for particles.

PURPOSE: Sets boundary conditions for particles. The basic algorithm is similar to the MHD boundary conditions. In setting B.C., particles are always packed to the send buffer (for both MPI and non-MPI cases), then unpacked with certain shifts in position or velocity. In the case of MPI, two communications are needed for sending and receiving particle, first on the number of particles to be sent/received, then to send/receive real data. The shearing box B.C. is first treated as periodic B.C., then move the particles in the ghost cells accordingly. Advection of particles when FARGO is turned on is also included.

CONTAINS PUBLIC FUNCTIONS:

PRIVATE FUNCTION PROTOTYPES:

History:

Definition in file bvals_particle.c.


Function Documentation

void advect_particles ( Grid *  pG,
Domain *  pD 
)

Advect particles by qshear*Omega_0*x1*dt for the FARGO algorithm.

Definition at line 922 of file bvals_particle.c.

References ath_error(), gridshift(), Lx2, my_iproc, my_jproc, my_kproc, n, Omega_0, packing_particle_fargo(), qshear, realloc_recvbuf(), recv_buf, recv_bufsize, send_buf, unpack_particle(), and x2min.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

static int gridshift ( Real  shift  )  [static]

Get the number of shift of grid in the y direction.

Definition at line 2612 of file bvals_particle.c.

Referenced by advect_particles().

Here is the caller graph for this function:

static void outflow_particle ( Grid *  pG  )  [static]

OUTFLOW boundary conditions.

For particles, outflow B.C. = No B.C. We only remove particles in the outermost layer of the ghost cells, which is done in remove_ghost_particle(), see particle.c.

Definition at line 1596 of file bvals_particle.c.

static long packing_ix1_particle ( Grid *  pG,
int  nlayer 
) [static]

Packing the particle inside the inner x1 boundary.

Input: pG: grid; nlayer: number of layers to be packed in the boundary Output: send_buf: buffer to save packed particle return: number of packed particle

Definition at line 1767 of file bvals_particle.c.

References n, packing_one_particle(), and send_buf.

Referenced by periodic_ox1_particle(), reflect_ix1_particle(), and set_bvals_particle().

Here is the call graph for this function:

Here is the caller graph for this function:

static long packing_ix1_particle_shear ( Grid *  pG,
int  reg,
long  numpar 
) [static]

Packing the particle inside the inner x1 boundary for shearing box.

Input: pG: grid; reg: region, 1 or 2 for mpi case, 0 for non-mpi case numpar: array index to start with. Return: number of packed particles in the specified region. Note: this routine serves for only 3D

Definition at line 2446 of file bvals_particle.c.

References Lx2, n, packing_one_particle(), send_buf, vshear, x2c, and x2min.

Referenced by shearingbox_ix1_particle().

Here is the call graph for this function:

Here is the caller graph for this function:

static long packing_ix2_particle ( Grid *  pG,
int  nlayer 
) [static]

Packing the particle inside the inner x2 boundary.

Input: pG: grid; nlayer: number of layers to be packed in the boundary Output: send_buf: buffer to save packed particle return: number of packed particle

Definition at line 1859 of file bvals_particle.c.

References n, packing_one_particle(), and send_buf.

Referenced by periodic_ox2_particle(), reflect_ix2_particle(), and set_bvals_particle().

Here is the call graph for this function:

Here is the caller graph for this function:

static long packing_ix3_particle ( Grid *  pG,
int  nlayer 
) [static]

Packing the particle inside the inner x3 boundary.

Input: pG: grid; nlayer: number of layers to be packed in the boundary Output: send_buf: buffer to save packed particle return: number of packed particle

Definition at line 1949 of file bvals_particle.c.

References n, packing_one_particle(), and send_buf.

Referenced by periodic_ox3_particle(), reflect_ix3_particle(), and set_bvals_particle().

Here is the call graph for this function:

Here is the caller graph for this function:

static void packing_one_particle ( Grain *  cur,
long  n,
short  pos 
) [static]

Subroutine for packing one particle to send buffer.

Input: cur: particle pointer; p: starting index in the buffer pos: particle position (0: ghost; 1: grid; 2: cross in/out; Output: one particle is added to the send buffer

Definition at line 2037 of file bvals_particle.c.

References realloc_sendbuf(), send_buf, and send_bufsize.

Referenced by packing_ix1_particle(), packing_ix1_particle_shear(), packing_ix2_particle(), packing_ix3_particle(), packing_ox1_particle(), packing_ox1_particle_shear(), packing_ox2_particle(), packing_ox3_particle(), and packing_particle_fargo().

Here is the call graph for this function:

Here is the caller graph for this function:

static long packing_ox1_particle ( Grid *  pG,
int  nlayer 
) [static]

Packing the particle inside the outer x1 boundary.

Input: pG: grid; nlayer: number of layers to be packed in the boundary Output: send_buf: buffer to save packed particle return: number of packed particle

Definition at line 1814 of file bvals_particle.c.

References n, packing_one_particle(), and send_buf.

Referenced by periodic_ix1_particle(), reflect_ox1_particle(), and set_bvals_particle().

Here is the call graph for this function:

Here is the caller graph for this function:

static long packing_ox1_particle_shear ( Grid *  pG,
int  reg,
long  numpar 
) [static]

Packing the particle outside the outer x1 boundary for shearing box.

Input: pG: grid; reg: region, 1 or 2 for mpi case, 0 for non-mpi case numpar: array index to start with. Return: number of packed particles in the specified region. Note: this routine serves for only 3D

Definition at line 2513 of file bvals_particle.c.

References Lx2, n, packing_one_particle(), send_buf, vshear, x2c, and x2min.

Referenced by shearingbox_ox1_particle().

Here is the call graph for this function:

Here is the caller graph for this function:

static long packing_ox2_particle ( Grid *  pG,
int  nlayer 
) [static]

Packing the particle inside the outer x2 boundary.

Input: pG: grid; nlayer: number of layers to be packed in the boundary Output: send_buf: buffer to save packed particle return: number of packed particle

Definition at line 1904 of file bvals_particle.c.

References n, packing_one_particle(), and send_buf.

Referenced by periodic_ix2_particle(), reflect_ox2_particle(), and set_bvals_particle().

Here is the call graph for this function:

Here is the caller graph for this function:

static long packing_ox3_particle ( Grid *  pG,
int  nlayer 
) [static]

Packing the particle inside the outer x3 boundary.

Input: pG: grid; nlayer: number of layers to be packed in the boundary Output: send_buf: buffer to save packed particle return: number of packed particle

Definition at line 1993 of file bvals_particle.c.

References n, and packing_one_particle().

Referenced by periodic_ix3_particle(), reflect_ox3_particle(), and set_bvals_particle().

Here is the call graph for this function:

Here is the caller graph for this function:

static long packing_particle_fargo ( Grid *  pG,
Real  yl,
Real  yu 
) [static]

Packing the particle for FARGO.

Input: pG: grid; yl, yu: lower and upper limit of x2 (y) coordinate for particles to be packed Return: number of packed particles in the specified region.

Definition at line 2581 of file bvals_particle.c.

References n, packing_one_particle(), and send_buf.

Referenced by advect_particles().

Here is the call graph for this function:

Here is the caller graph for this function:

static void periodic_ix1_particle ( Grid *  pG  )  [static]

PERIODIC boundary conditions, Inner x1 boundary (ibc_x1=4).

Note: 2D shearing box B.C. is considered here!

Definition at line 1607 of file bvals_particle.c.

References Lx1, n, packing_ox1_particle(), send_buf, shift_packed_particle(), unpack_particle(), and vshear.

Here is the call graph for this function:

static void periodic_ix2_particle ( Grid *  pG  )  [static]

PERIODIC boundary conditions, Inner x2 boundary (ibc_x2=4).

Definition at line 1681 of file bvals_particle.c.

References Lx2, n, packing_ox2_particle(), send_buf, shift_packed_particle(), and unpack_particle().

Here is the call graph for this function:

static void periodic_ix3_particle ( Grid *  pG  )  [static]

PERIODIC boundary conditions, Inner x3 boundary (ibc_x3=4).

Definition at line 1721 of file bvals_particle.c.

References Lx3, n, packing_ox3_particle(), send_buf, shift_packed_particle(), and unpack_particle().

Here is the call graph for this function:

static void periodic_ox1_particle ( Grid *  pG  )  [static]

PERIODIC boundary conditions, Outer x1 boundary (ibc_x1=4).

Note: 2D shearing box B.C. is considered here!

Definition at line 1645 of file bvals_particle.c.

References Lx1, n, packing_ix1_particle(), send_buf, shift_packed_particle(), unpack_particle(), and vshear.

Here is the call graph for this function:

static void periodic_ox2_particle ( Grid *  pG  )  [static]

PERIODIC boundary conditions, Outer x2 boundary (ibc_x2=4).

Definition at line 1701 of file bvals_particle.c.

References Lx2, n, packing_ix2_particle(), send_buf, shift_packed_particle(), and unpack_particle().

Here is the call graph for this function:

static void periodic_ox3_particle ( Grid *  pG  )  [static]

PERIODIC boundary conditions, Outer x3 boundary (ibc_x3=4).

Definition at line 1741 of file bvals_particle.c.

References Lx3, n, packing_ix3_particle(), send_buf, shift_packed_particle(), and unpack_particle().

Here is the call graph for this function:

static void realloc_recvbuf (  )  [static]

Reallocate memory to receive buffer.

Definition at line 1366 of file bvals_particle.c.

References ath_error(), ath_pout(), NBUF, recv_buf, and recv_bufsize.

Referenced by advect_particles(), set_bvals_particle(), shearingbox_ix1_particle(), and shearingbox_ox1_particle().

Here is the call graph for this function:

Here is the caller graph for this function:

static void realloc_sendbuf (  )  [static]

Reallocate memory to send buffer.

Definition at line 1352 of file bvals_particle.c.

References ath_error(), ath_pout(), NBUF, send_buf, and send_bufsize.

Referenced by packing_one_particle().

Here is the call graph for this function:

Here is the caller graph for this function:

static void reflect_ix1_particle ( Grid *  pG  )  [static]

REFLECTING boundary conditions, Inner x1 boundary (ibc_x1=1).

Definition at line 1405 of file bvals_particle.c.

References n, packing_ix1_particle(), send_buf, and unpack_particle().

Here is the call graph for this function:

static void reflect_ix2_particle ( Grid *  pG  )  [static]

REFLECTING boundary conditions, Inner x2 boundary (ibc_x2=1).

Definition at line 1467 of file bvals_particle.c.

References n, packing_ix2_particle(), send_buf, and unpack_particle().

Here is the call graph for this function:

static void reflect_ix3_particle ( Grid *  pG  )  [static]

REFLECTING boundary conditions, Inner x3 boundary (ibc_x3=1).

Definition at line 1529 of file bvals_particle.c.

References n, packing_ix3_particle(), send_buf, and unpack_particle().

Here is the call graph for this function:

static void reflect_ox1_particle ( Grid *  pG  )  [static]

REFLECTING boundary conditions, Outer x1 boundary (ibc_x1=1).

Definition at line 1436 of file bvals_particle.c.

References n, packing_ox1_particle(), send_buf, and unpack_particle().

Here is the call graph for this function:

static void reflect_ox2_particle ( Grid *  pG  )  [static]

REFLECTING boundary conditions, Outer x2 boundary (ibc_x2=1).

Definition at line 1498 of file bvals_particle.c.

References n, packing_ox2_particle(), send_buf, and unpack_particle().

Here is the call graph for this function:

static void reflect_ox3_particle ( Grid *  pG  )  [static]

REFLECTING boundary conditions, Outer x3 boundary (ibc_x3=1).

Definition at line 1560 of file bvals_particle.c.

References n, packing_ox3_particle(), send_buf, and unpack_particle().

Here is the call graph for this function:

void set_bvals_particle ( Grid *  pG,
Domain *  pD 
)

Calls appropriate functions to set particle BCs.

The function pointers (*apply_???) are set during initialization by set_bvals_particle_init() to be either a user-defined function, or one of the functions corresponding to reflecting, periodic, or outflow. If the left- or right-Grid ID numbers are >= 1 (neighboring grids exist), then MPI calls are used.

Order for updating boundary conditions must always be x1-x2-x3 in order to fill the corner cells properly

Definition at line 160 of file bvals_particle.c.

References ath_error(), Lx1, Lx2, Lx3, my_iproc, my_jproc, my_kproc, NShuffle, packing_ix1_particle(), packing_ix2_particle(), packing_ix3_particle(), packing_ox1_particle(), packing_ox2_particle(), packing_ox3_particle(), realloc_recvbuf(), recv_buf, recv_bufsize, send_buf, shearingbox_ix1_particle(), shearingbox_ox1_particle(), shift_packed_particle(), shuffle(), unpack_particle(), update_particle_status(), and vshear.

Here is the call graph for this function:

void set_bvals_particle_destruct ( Grid *  pG,
Domain *  pD 
)

Finalize boundary condition.

Definition at line 1319 of file bvals_particle.c.

References apply_ix1, apply_ix2, apply_ix3, apply_ox1, apply_ox2, apply_ox3, recv_buf, recv_bufsize, send_buf, and send_bufsize.

void set_bvals_particle_fun ( enum Direction  dir,
VBCFun_t  prob_bc 
)

Sets function pointers for user-defined BCs in problem file.

Definition at line 1289 of file bvals_particle.c.

References apply_ix1, apply_ix2, apply_ix3, apply_ox1, apply_ox2, apply_ox3, ath_perr(), left_x1, left_x2, left_x3, right_x1, right_x2, and right_x3.

Here is the call graph for this function:

void set_bvals_particle_init ( Grid *  pG,
Domain *  pD 
)

Sets function pointers for physical boundaries during initialization, allocates memory for send/receive buffers with MPI.

Definition at line 1023 of file bvals_particle.c.

References apply_ix1, apply_ix2, apply_ix3, apply_ox1, apply_ox2, apply_ox3, ath_perr(), calloc_1d_array(), get_myGridIndex(), kb, Lx1, Lx2, Lx3, my_iproc, my_jproc, my_kproc, nbc, NBUF, NShuffle, Omega_0, par_getd(), par_geti(), par_geti_def(), qshear, recv_buf, recv_bufsize, send_buf, send_bufsize, vshear, x1max, x1min, x2max, x2min, x3max, and x3min.

Here is the call graph for this function:

static void shearingbox_ix1_particle ( Grid *  pG,
Domain *  pD,
long  numpar 
) [static]

Shearing box boundary condition, Inner x1 boundary (ibc_x1=4).

This routine works for only 3D. Input: numpar: for the packing routine, the array index to start with.

Definition at line 2141 of file bvals_particle.c.

References ath_error(), Lx2, my_jproc, my_kproc, n1, n2, packing_ix1_particle_shear(), realloc_recvbuf(), recv_buf, recv_bufsize, send_buf, unpack_particle(), and vshear.

Referenced by set_bvals_particle().

Here is the call graph for this function:

Here is the caller graph for this function:

static void shearingbox_ox1_particle ( Grid *  pG,
Domain *  pD,
long  numpar 
) [static]

Shearing box boundary condition, Outer x1 boundary (obc_x1=4).

This routine works for only 3D. Input: numpar: for the packing routine, the array index to start with.

Definition at line 2293 of file bvals_particle.c.

References ath_error(), Lx2, my_jproc, my_kproc, n1, n2, packing_ox1_particle_shear(), realloc_recvbuf(), recv_buf, recv_bufsize, send_buf, unpack_particle(), and vshear.

Referenced by set_bvals_particle().

Here is the call graph for this function:

Here is the caller graph for this function:

static void shift_packed_particle ( double *  buf,
long  n,
int  index,
double  shift 
) [static]

shift the coordinate/velocity of the packed particles by a constant amount

Input: buf: buffer; n: number of particles in the buffer index: 1: x1; 2: x2; 3: x3; 4: v1; 5: v2; 6: v3; shift: amount of change. Output: buf: buffer with shifted particles

Definition at line 2075 of file bvals_particle.c.

Referenced by periodic_ix1_particle(), periodic_ix2_particle(), periodic_ix3_particle(), periodic_ox1_particle(), periodic_ox2_particle(), periodic_ox3_particle(), and set_bvals_particle().

Here is the caller graph for this function:

static void unpack_particle ( Grid *  pG,
double *  buf,
long  n 
) [static]

Unpack received particle Input: pG: grid; buf: received buffer n: number of particle in the buffer Output: pG: grid with new particle added.

Definition at line 2100 of file bvals_particle.c.

References particle_realloc().

Referenced by advect_particles(), periodic_ix1_particle(), periodic_ix2_particle(), periodic_ix3_particle(), periodic_ox1_particle(), periodic_ox2_particle(), periodic_ox3_particle(), reflect_ix1_particle(), reflect_ix2_particle(), reflect_ix3_particle(), reflect_ox1_particle(), reflect_ox2_particle(), reflect_ox3_particle(), set_bvals_particle(), shearingbox_ix1_particle(), and shearingbox_ox1_particle().

Here is the call graph for this function:

Here is the caller graph for this function:

static void update_particle_status ( Grid *  pG  )  [static]

Update the status of the particles after applying boundary conditions.

Definition at line 1381 of file bvals_particle.c.

References x1lpar, x1upar, x2lpar, x2upar, x3lpar, and x3upar.

Referenced by set_bvals_particle().

Here is the caller graph for this function:


Variable Documentation

VBCFun_t apply_ix1 = NULL [static]
VBCFun_t apply_ix2 = NULL [static]
VBCFun_t apply_ix3 = NULL [static]
VBCFun_t apply_ox1 = NULL [static]
VBCFun_t apply_ox2 = NULL [static]
VBCFun_t apply_ox3 = NULL [static]
Real Lx1 [static]
Real Lx2 [static]
Real Lx3 [static]
int my_iproc [static]
int my_jproc [static]
int my_kproc [static]
int nbc [static]

Definition at line 68 of file bvals_particle.c.

Referenced by set_bvals_particle_init().

long NBUF [static]

Definition at line 65 of file bvals_particle.c.

Referenced by realloc_recvbuf(), realloc_sendbuf(), and set_bvals_particle_init().

int NShuffle [static]

Definition at line 75 of file bvals_particle.c.

Referenced by set_bvals_particle(), and set_bvals_particle_init().

double * recv_buf = NULL [static]
long recv_bufsize [static]
double* send_buf = NULL [static]
long send_bufsize [static]
Real x1max [static]
Real x1min [static]
Real x2max [static]
Real x2min [static]
Real x3max [static]
Real x3min [static]