diff options
Diffstat (limited to 'src/GHExtension.c')
-rw-r--r-- | src/GHExtension.c | 132 |
1 files changed, 108 insertions, 24 deletions
diff --git a/src/GHExtension.c b/src/GHExtension.c index e097add..eebb0cb 100644 --- a/src/GHExtension.c +++ b/src/GHExtension.c @@ -19,11 +19,16 @@ #include "cctk.h" #include "cctk_parameters.h" +#include "cctk_ParameterFunctions.h" #include "CactusPUGH/PUGH/src/include/pugh.h" #include "CactusBase/IOUtil/src/ioGH.h" #include "ioFlexGH.h" +/* local function prototypes */ +void SetupSliceCenter (cGH *GH); + + void *IOFlexIO_SetupGH (tFleshConfig *config, int convergence_level, cGH *GH) { int i, numvars; @@ -32,10 +37,10 @@ void *IOFlexIO_SetupGH (tFleshConfig *config, int convergence_level, cGH *GH) numvars = CCTK_NumVars (); newGH = (flexioGH *) malloc (sizeof (flexioGH)); - newGH->IO_2Dnum = (int *) malloc (numvars * sizeof (int)); - newGH->IO_3Dnum = (int *) malloc (numvars * sizeof (int)); - newGH->IO_2Dlast = (int *) malloc (numvars * sizeof (int)); - newGH->IO_3Dlast = (int *) malloc (numvars * sizeof (int)); + newGH->do_out2D = (char *) malloc (numvars * sizeof (char)); + newGH->do_out3D = (char *) malloc (numvars * sizeof (char)); + newGH->out2D_last = (int *) malloc (numvars * sizeof (int)); + newGH->out3D_last = (int *) malloc (numvars * sizeof (int)); newGH->IEEEfname_3D = (char **) malloc (numvars * sizeof (char **)); @@ -52,42 +57,48 @@ int IOFlexIO_InitGH (cGH *GH) int i; ioGH *ioUtilGH; flexioGH *myGH; + t_param_prop *param_prop; + /* get the handles for IOUtil and IOFlexIO extensions */ ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")]; myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")]; /* How often to output */ - myGH->IO_2Devery = out_every > 0 ? out_every : -1; - myGH->IO_3Devery = out_every > 0 ? out_every : -1; + myGH->out2D_every = out_every > 0 ? out_every : -1; + myGH->out3D_every = out_every > 0 ? out_every : -1; if (out2D_every > 0) - myGH->IO_2Devery = out2D_every; + myGH->out2D_every = out2D_every; if (out3D_every > 0) - myGH->IO_3Devery = out3D_every; + myGH->out3D_every = out3D_every; - InitIONum (myGH->IO_2Dnum, out2D_vars); - InitIONum (myGH->IO_3Dnum, out3D_vars); + ParseVarsForOutput (out2D_vars, myGH->do_out2D); + ParseVarsForOutput (out3D_vars, myGH->do_out3D); - /* Deal with the output directories */ - myGH->outpfx_2D = outdir; - myGH->outpfx_3D = outdir; - if (!CCTK_Equals(outdir2D,"outdir")) - myGH->outpfx_2D = outdir2D; - if (!CCTK_Equals(outdir3D,"outdir")) - myGH->outpfx_3D = outdir3D; + /* Check whether "outdir2D" and/or "outdir3D" was set. + If so take these dirs otherwise default to "IO::outdir" */ + param_prop = CCTK_ParameterInfo ("outdir2D", CCTK_THORNSTRING); + if (param_prop && param_prop->n_set > 0) + myGH->outdir2D = outdir2D; + else + myGH->outdir2D = outdir; + + param_prop = CCTK_ParameterInfo ("outdir3D", CCTK_THORNSTRING); + if (param_prop && param_prop->n_set > 0) + myGH->outdir3D = outdir3D; + else + myGH->outdir3D = outdir; /* Create the output directories */ if (CCTK_MyProc (GH) == 0) { - if (myGH->IO_2Devery > 0 && strcmp (myGH->outpfx_2D, ".")) - if (CCTK_mkdir (myGH->outpfx_2D) != 0) - CCTK_WARN (2,"Problem creating IO 2D directory"); - if (myGH->IO_3Devery > 0 && strcmp (myGH->outpfx_3D, ".")) - if (CCTK_mkdir (myGH->outpfx_3D) != 0) - CCTK_WARN (2,"Problem creating IO 3D directory"); + if (CCTK_mkdir (myGH->outdir2D) != 0) + CCTK_WARN (2,"Problem creating IO 2D directory"); + if (CCTK_mkdir (myGH->outdir3D) != 0) + CCTK_WARN (2,"Problem creating IO 3D directory"); } for (i=0; i<CCTK_NumVars(); i++) - myGH->IO_2Dlast [i] = myGH->IO_3Dlast [i] = -1; + myGH->out2D_last [i] = myGH->out3D_last [i] = -1; myGH->out3d_reuse_filehandles = out3d_reuse_filehandles; @@ -108,5 +119,78 @@ int IOFlexIO_InitGH (cGH *GH) myGH->filenameList2D = NULL; myGH->fileList_3D = NULL; + /* set up 2D planes to plot */ + SetupSliceCenter (GH); + return (0); } + + +/****************************************************************************/ +/* local routines */ +/****************************************************************************/ +void SetupSliceCenter (cGH *GH) +{ + DECLARE_CCTK_PARAMETERS + int dim; + int slice_center; + pGH *pughGH; + flexioGH *myGH; + + + /* Get the handles for PUGH IOFlexIO extensions */ + pughGH = (pGH *) GH->extensions [CCTK_GHExtensionHandle ("PUGH")]; + myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")]; + + slice_center=1; + if ( CCTK_Equals (domain, "octant") + || CCTK_Equals (domain, "quadrant") + || CCTK_Equals (domain, "bitant")) + 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) */ + + for (dim = 0; dim < GH->cctk_dim; dim++) + if (pughGH->lnsize [dim] == 1) + myGH->sp2xyz [dim] = 0; + else + myGH->sp2xyz [dim] = pughGH->nsize [dim]/2 - + pughGH->lb [pughGH->myproc][dim]; + + } + + /* for octant mode, the slicing center is the index 1 or zero*/ + else + + { + for (dim = 0; dim < GH->cctk_dim; dim++) + if (pughGH->lnsize [dim] == 1) + myGH->sp2xyz [dim] = 0; + else + myGH->sp2xyz [dim] = 1 - pughGH->lb [pughGH->myproc][dim]; + } + + /* In quadrant mode x and y are like full, but z is like octant */ + if (CCTK_Equals (domain, "quadrant")) { + if (pughGH->lnsize [2] == 1) + myGH->sp2xyz[2] = 0; + else + myGH->sp2xyz[2] = pughGH->lnsize [2]/2 - pughGH->lb [pughGH->myproc][2]; + } + + if (CCTK_Equals (domain, "bitant")) { + if (pughGH->lnsize [0] == 1) + myGH->sp2xyz[0] = 0; + else + myGH->sp2xyz[0] = myGH->sp2xyz[0]/2 - pughGH->lb [pughGH->myproc][0]; + + if (pughGH->lnsize [1] == 1) + myGH->sp2xyz[1] = 0; + else + myGH->sp2xyz[1] = pughGH->lnsize [1]/2 - pughGH->lb [pughGH->myproc][1]; + } +} |