PLUTO
4.4-patch2
|
Miscellaneous functions for implementing the shearing-box boundary condition. More...
#include "pluto.h"
Functions | |
void | SB_SetBoundaryVar (double ***U, RBox *box, int side, double t, Grid *grid) |
void | SB_ShiftBoundaryVar (double ***q, RBox *box, int side, double t, Grid *grid) |
void | SB_FillBoundaryGhost (double ***U, RBox *box, int nghL, int nghR, Grid *grid) |
void | SB_ShearingInterp (double *qL, double *qR, double t, int side, Grid *grid) |
int | SB_JSHIFT (int jc) |
The shearing-box tool file contains various functions for the implementation of the shearingbox boundary conditions in serial or parallel mode. The SB_SetBoundaryVar() function applies shearing-box boundary conditions to a 3D array U[k][j][i] at an X1_BEG or X1_END boundary. The array U[k][j][i] is defined on the RBox *box with grid indices (box->ibeg) <= i <= (box->iend), (box->jbeg) <= j <= (box->jend) (box->kbeg) <= k <= (box->kend),
and assumes that periodic boundary conditions have already been set. Indices in the y-directions are not necessary, since the entire y-range is assumed.
In parallel mode, we use the SB_ShiftBoundaryVar() function to perform the integer shift of cells across the processors, while interpolation function SB_ShearingInterp() handles the fractional part only. In serial or when there's only 1 processor along y, the interpolation function does all the job (integer+fractional).
Fill ghost zones in the Y direction in the X1_BEG and X1_END boundary regions.
[in,out] | U | a 3D data array |
[in,out] | box | the RBox structure containing the grid indices in the x and z directions. Indices in the y-directions are reset here for convenience. |
[in] | nghL | number of ghost zones on the left |
[in] | nghR | number of ghost zones on the right |
[in] | grid | pointer to a Grid structure |
int SB_JSHIFT | ( | int | jc | ) |
Make sure jc always fall between JBEG and JEND
Fill ghost zones using shearing-box conditions.
[out] | U | pointer to a 3D array (centered or staggered) |
[in] | box | pointer to RBox structure defining the domain sub-portion over which shearing-box conditions have to be applied |
[in] | side | the side of the X1 boundary (X1_BEG or X1_END) |
[in] | t | the simulation time |
[in] | grid | pointer to an array of Grid structures |
void SB_ShearingInterp | ( | double * | qL, |
double * | qR, | ||
double | t, | ||
int | side, | ||
Grid * | grid | ||
) |
Shift the 1D arrays qL or qR by an amount (if there's only one processor in y) or just by
(otherwise) by advecting the initial profile of qR (when side == X1_BEG) or qL (when side == X1_END).
[in,out] | qL | 1D array containing the un-shifted values on the left boundary |
[in,out] | qR | 1D array containing the un-shifted values on the right boundary |
[in] | t | simulation time |
[in] | side | boundary side |
[in] | grid | pointer to an array of Grid structures |
Split the 3D array q[k][j][i] in two buffers and send them to processors with rank dst1 and dst2. The box structure contains the original grid index ranges on top of which q is defined. At the same time, receive buffers from processors with rank src1,src2.
[in,out] | q | 3D array |
[in] | box | the rectangular box giving the index range |
[in] | side | the side of the X1 boundary |
[in] | t | simulation time |
[in] | grid | pointer to an array of Grid structures |
We allocate static memory areas for send/receive buffers and employ just one send buffer and one receive buffer with size equals the full extent of the boundary side. The two data chunks coming from q[k][j][i] are stored at different positions in the send/recv buffers.
In 3D staggered MHD we augment the buffer size by 1 point in the z-direction for BZs. There's no need to do the same for BYs periodic condition will be applied later on.
Depending on the boundary side, we set buffer offsets in the y-direction and find the ranks of the processors to/from which we must send/receive data. Local processor sends data to processors dst1 and dst2 and receive data from processors src1 and src2.
|________________| |_____[dst1]_____||____[dst2]______| <----><--------> <----> <--------> buf1 buf2 buf1 buf2