diff options
Diffstat (limited to 'src/pugh/SetupSliceCenter.c')
-rw-r--r-- | src/pugh/SetupSliceCenter.c | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/src/pugh/SetupSliceCenter.c b/src/pugh/SetupSliceCenter.c new file mode 100644 index 0000000..58e6a07 --- /dev/null +++ b/src/pugh/SetupSliceCenter.c @@ -0,0 +1,137 @@ + /*@@ + @file SetupSliceCenter.c + @date + @author + @desc + @enddesc + @version $Id$ + @@*/ + +#include "pugh.h" + +static char *rcsid = "$Id$"; + +void SetupSliceCenter(pGH *GH) { + int slice_center; + + + /* slice_center used to be part of the GF, */ + /* either 1 (default) or 0 (octant,edge)*/ + /* now spxyz[0],spxyz[1],spxyz[2] are part of the GH */ + + if ((GH->spxyz[0]!=-1)||(GH->spxyz[1]!=-1)||(GH->spxyz[2]!=-1)) { + printf("WARNING in SetupSliceCenter: you already have these Slice Center settings:\n(OK for BoxInBox)"); + printf("spxyz[0],spxyz[1],spxyz[2]: %d %d %d \n", + GH->spxyz[0], GH->spxyz[1], GH->spxyz[2]); + return; + } + + slice_center=1; + if (Contains("grid","octant") || Contains("grid","quadrant") || + Contains("grid","bitant")) + slice_center=0; + if (Contains("slice_loc","edge")) slice_center=0; + + if (slice_center) { + /* For NONE octant mode: the center for slicings */ + /* is moved to the center index */ + /* (unless nx,ny,nz=1) */ + if (GH->nx == 1) { + GH->spxyz[0] = 0; + GH->sp2dxyz[0] = 0; + } else { + GH->spxyz[0] = GH->nx/2 - GH->lb[GH->myproc][0]; + GH->sp2dxyz[0] = GH->nx/2 - GH->lb[GH->myproc][0]; + } + + if (GH->ny == 1) { + GH->spxyz[1] = 0; + GH->sp2dxyz[1] = 0; + } else { + GH->spxyz[1] = GH->ny/2 - GH->lb[GH->myproc][1]; + GH->sp2dxyz[1] = GH->ny/2 - GH->lb[GH->myproc][1]; + } + + if (GH->nz == 1) { + GH->spxyz[2] = 0; + GH->sp2dxyz[2] = 0; + } else { + GH->spxyz[2] = GH->nz/2 - GH->lb[GH->myproc][2]; + GH->sp2dxyz[2] = GH->nz/2 - GH->lb[GH->myproc][2]; + } + } + /* for octant mode, the slicing center is the index 1 or zero*/ + else { + if (GH->nx == 1) { + GH->spxyz[0] = 0; + GH->sp2dxyz[0] = 0; + } else { + GH->spxyz[0] = 1 - GH->lb[GH->myproc][0]; + GH->sp2dxyz[0] = 1 - GH->lb[GH->myproc][0]; + } + + if (GH->ny == 1) { + GH->spxyz[1] = 0; + GH->sp2dxyz[1] = 0; + } else { + GH->spxyz[1] = 1 - GH->lb[GH->myproc][1]; + GH->sp2dxyz[1] = 1 - GH->lb[GH->myproc][1]; + } + + if (GH->nz == 1) { + GH->spxyz[2] = 0; + GH->sp2dxyz[2] = 0; + } else { + GH->spxyz[2] = 1 - GH->lb[GH->myproc][2]; + GH->sp2dxyz[2] = 1 - GH->lb[GH->myproc][2]; + } + } + + /* Special case: in quadrant mode x and y are like full, but + z is like octant. Thinking about this gives you a headache, + but works. + */ + if (Contains("grid","quadrant")) { + if (GH->nz == 1) { + GH->spxyz[2] = 0; + GH->sp2dxyz[2] = 0; + } else { + GH->spxyz[2] = GH->nz/2 - GH->lb[GH->myproc][2]; + GH->sp2dxyz[2] = GH->nz/2 - GH->lb[GH->myproc][2]; + } + } + + /* Another special case: bitant! Hey, with full and octant + already implemented, bitant is a breeze on the neurons */ + if (Contains("grid","bitant")) + { if (GH->nx == 1) + { GH->spxyz[0] = 0; + GH->sp2dxyz[0] = 0; + } + else + { GH->spxyz[0] = GH->nx/2 - GH->lb[GH->myproc][0]; + GH->sp2dxyz[0] = GH->nx/2 - GH->lb[GH->myproc][0]; + } + if (GH->ny == 1) + { GH->spxyz[1] = 0; + GH->sp2dxyz[1] = 0; + } + else + { GH->spxyz[1] = GH->ny/2 - GH->lb[GH->myproc][1]; + GH->sp2dxyz[1] = GH->ny/2 - GH->lb[GH->myproc][1]; + } + } + +#ifdef THORN_CARTOON_2D + /* for cartoon_2d, treat x as in octant, y and z as in full, BB */ + if (Contains("cartoon_active","yes")) { + if (GH->nx == 1) { + GH->spxyz[0] = 0; + GH->sp2dxyz[0] = 0; + } else { + GH->spxyz[0] = 1 - GH->lb[GH->myproc][0]; + GH->sp2dxyz[0] = 1 - GH->lb[GH->myproc][0]; + } + } +#endif +} |