Esempio n. 1
0
/*@@
   @routine    IOASCII_TriggerOutput1D
   @date       Sat March 6 1999
   @author     Gabrielle Allen
   @desc
               Triggers the output a variable
               using the IOASCII output method method
   @enddesc
   @calls      IOASCII_Write1D

   @var        GH
   @vdesc      Pointer to CCTK GH
   @vtype      const cGH *
   @vio        in
   @endvar
   @var        vindex
   @vdesc      index of variable to output
   @vtype      int
   @vio        in
   @endvar

   @returntype int
   @returndesc
               return code of @seeroutine IOASCII_Write1D
   @endreturndesc
@@*/
int IOASCII_TriggerOutput1D (const cGH *GH, int vindex)
{
  int retval;
  const char *var;
  asciiioGH *myGH;


  myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII");

  var = CCTK_VarName (vindex);

  /* Do the 1D output */
#ifdef IO_DEBUG
  printf ("\nIn IOASCII TriggerOutput1D\n---------------------\n");
  printf ("  Index = %d\n", vindex);
  printf ("  Variable = -%s-\n", var);
#endif

  retval = IOASCII_Write1D (GH, vindex, var);

  if (retval == 0)
  {
    /* Register variables as having 1D output this iteration */
    myGH->out1D_last[vindex] = GH->cctk_iteration;
  }

  return (retval);
}
Esempio n. 2
0
int SetCartSymGI(cGH *GH, int *sym, int gi) 
{
  
  DECLARE_CCTK_PARAMETERS

  int domainsym[MAX_FACE];
  SymmetryGHex *sGHex; 
  int first_vari,numvars,vi;
  int dir;
  
  sGHex  = (SymmetryGHex *)GH->extensions[CCTK_GHExtensionHandle("Symmetry")];

  first_vari = CCTK_FirstVarIndexI(gi);
  numvars    = CCTK_NumVarsInGroupI(gi);

  if (first_vari<0)
  {
    CCTK_VWarn(1,__LINE__,__FILE__,CCTK_THORNSTRING,
	       "Cannot find group %s (grp.index: %d) in SetCartSymGI",
	       CCTK_GroupName(gi),first_vari);
    return(-1);
  }

  /* Reference the hash table in the GHex and tell it what kind of
     symmetry is being applied 
     (depending on sym and the grid layout) 
     If there is no symmetry necessary,set ESYM_NOSYM
     When we apply a symmetry and find ESYM_UNSET, something went wrong! 
   */
  for (vi=first_vari; vi<first_vari+numvars; vi++) 
  {

#ifdef SYM_DEBUG
    printf("SetSymmetry: %s   [%d,%d,%d]\n",CCTK_VarName(vi), 
	   sym[0],sym[1],sym[2]);
#endif
    
    DecodeSymParameters3D (domainsym);
    for (dir=0; dir<MAX_FACE; dir++) 
    {
      if (domainsym[dir]) 
      {
	sGHex->GFSym[vi][dir] = sym[dir/2];
      }
      else 
      {
	sGHex->GFSym[vi][dir] = GFSYM_NOSYM;
      }
    }

#ifdef SYM_DEBUG
    printf("SetSymmetry: %s   [%d,%d,%d]\n\n",imp_gf, 
	   sGHex->GFSym[vi][0],
	   sGHex->GFSym[vi][2],
	   sGHex->GFSym[vi][4]);
#endif
  }
  USE_CCTK_PARAMETERS;   return(0);
}
Esempio n. 3
0
/*@@
   @routine    IOBasic_ScalarOutputGH
   @date       Sat March 6 1999
   @author     Gabrielle Allen
   @desc
               Loops over all variables and outputs them if necessary
   @enddesc
   @calls      IOBasic_TimeForScalarOutput
               IOBasic_WriteScalarGS
               IOBasic_WriteScalarGA

   @var        GH
   @vdesc      Pointer to CCTK GH
   @vtype      const cGH *
   @vio        in
   @endvar

   @returntype int
   @returndesc
               the number of variables which were output at this iteration
               (or 0 if it wasn't time to output yet)
   @endreturndesc
@@*/
int IOBasic_ScalarOutputGH (const cGH *GH)
{
  int i, vindex, retval;
  const char *name;
  iobasicGH *myGH;


  /* Get the GH extensions for IOBasic */
  myGH = (iobasicGH *) CCTK_GHExtension (GH, "IOBasic");

  CheckSteerableParameters (myGH);

  /* Return if no output is required */
  if (myGH->outScalar_every <= 0)
  {
    return (0);
  }

  /* Loop over all variables */
  for (vindex = retval = 0; vindex < CCTK_NumVars (); vindex++)
  {
    /* Is it time for output ? */
    if (! IOBasic_TimeForScalarOutput (GH, vindex))
    {
      continue;
    }

    /* Get the variable name for this index (for filename) */
    name = CCTK_VarName (vindex);

#ifdef IOBASIC_DEBUG
    printf("\nIn IOBasic_ScalarOutputGH\n----------------\n");
    printf("  Index = %d\n",vindex);
    printf("  Variable = -%s-\n",name);
    printf("  Last output iteration was = %d\n",myGH->outScalar_last[vindex]);
#endif

    /* Make the IO call */
    if (CCTK_GroupTypeFromVarI (vindex) == CCTK_SCALAR)
    {
      i = IOBasic_WriteScalarGS (GH, vindex, name);
    }
    else
    {
      i = IOBasic_WriteScalarGA (GH, vindex, name);
    }
    if (i == 0)
    {
      /* Register GF as having 0D output this iteration */
      myGH->outScalar_last [vindex] = GH->cctk_iteration;
      retval++;
    }
  } /* end of loop over all variables */

  return (retval);
}
Esempio n. 4
0
/*@@
   @routine    IOASCII_Output1DGH
   @date       Sat March 6 1999
   @author     Gabrielle Allen
   @desc
               Loops over all variables and outputs them if necessary
   @enddesc
   @calls      IOASCII_TimeFor1D
               IOASCII_Write1D

   @var        GH
   @vdesc      Pointer to CCTK GH
   @vtype      const cGH *
   @vio        in
   @endvar

   @returntype int
   @returndesc
               the number of variables which were output at this iteration
               (or 0 if it wasn't time to output yet)
   @endreturndesc
@@*/
int IOASCII_Output1DGH (const cGH *GH)
{
  int vindex, retval;
  asciiioGH *myGH;
  const char *name;


  /* Get the GH extensions for IOASCII */
  myGH = (asciiioGH *) CCTK_GHExtension (GH, "IOASCII");

  CheckSteerableParameters (myGH);

  /* Return if no output is required */
  if (myGH->out1D_every <= 0)
  {
    return (0);
  }

  /* Loop over all variables */
  for (vindex = retval = 0; vindex < CCTK_NumVars (); vindex++)
  {
    /* Check if this variable should be output */
    if (! IOASCII_TimeFor1D (GH, vindex))
    {
       continue;
    }

    /* Get the variable name for this index (for filename) */
    name = CCTK_VarName (vindex);

#ifdef IO_DEBUG
    printf ("\nIn IOASCII Output1DGH\n---------------------\n");
    printf ("  Index = %d\n", vindex);
    printf ("  Variable = -%s-\n", name);
    printf ("  On iteration %d\n", GH->cctk_iteration);
    printf ("  Last output iteration was = %d\n", myGH->out1D_last[vindex]);
#endif

    /* Make the IO call */
    if (IOASCII_Write1D (GH, vindex, name) == 0)
    {
      /* Register variable as having 1D output this iteration */
      myGH->out1D_last[vindex] = GH->cctk_iteration;
      retval++;
    }
  } /* end of loop over all variables */

  return (retval);
}
Esempio n. 5
0
int SetCartSymVI(cGH *GH, int *sym, int vi) 
{
  
  DECLARE_CCTK_PARAMETERS

  int domainsym[MAX_FACE];
  SymmetryGHex *sGHex;
  int dir;
  
  /* Pointer to the SymmetryGHextension */
  sGHex  = (SymmetryGHex *)GH->extensions[CCTK_GHExtensionHandle("Symmetry")];

  /* Reference the hash table in the GHex and tell it what kind of
     symmetry is being applied 
     (depending on sym and the grid layout) 
     If there is no symmetry necessary,set ESYM_NOSYM
     When we apply a symmetry and find ESYM_UNSET, something went wrong! 
   */

#ifdef SYM_DEBUG
  printf("SetSymmetry: %s   [%d,%d,%d]\n",CCTK_VarName(vi), sym[0],sym[1],sym[2]);
#endif
  
  DecodeSymParameters3D(domainsym);
  for (dir=0; dir<MAX_FACE; ++dir) 
  {
    if (domainsym[dir]) 
    {
      sGHex->GFSym[vi][dir] = sym[dir/2];
    } 
    else 
    {
      sGHex->GFSym[vi][dir] = GFSYM_NOSYM;
    }
  }

#ifdef SYM_DEBUG
  printf("SetSymmetry: %s   [%d,%d,%d]\n\n",imp_gf, 
	 sGHex->GFSym[vi][0],
	 sGHex->GFSym[vi][2],
	 sGHex->GFSym[vi][4]);
#endif
  USE_CCTK_PARAMETERS;   return 0;
}
Esempio n. 6
0
/*@@
   @routine    IOBasic_TriggerScalarOutput
   @date       Sat March 6 1999
   @author     Gabrielle Allen
   @desc
               Triggers the output of a variable using IOBasic's Scalar
               output method
   @enddesc

   @var        GH
   @vdesc      Pointer to CCTK GH
   @vtype      const cGH *
   @vio        in
   @endvar
   @var        vindex
   @vdesc      index of variable to output
   @vtype      int
   @vio        in
   @endvar

   @returntype int
   @returndesc
               return code of @seeroutine IOBasic_WriteScalarGS or
               @seeroutine IOBasic_WriteScalarGA
   @endreturndesc
@@*/
int IOBasic_TriggerScalarOutput (const cGH *GH, int vindex)
{
  int retval;
  const char *name;
  iobasicGH *myGH;


  /* Get the GH extension for IOBasic */
  myGH = (iobasicGH *) CCTK_GHExtension (GH, "IOBasic");

  name = CCTK_VarName (vindex);

#ifdef IOBASIC_DEBUG
  printf ("\nIn IOBasic_TriggerScalarOutput\n---------------------\n");
  printf ("  Index = %d\n", vindex);
  printf ("  Variable = -%s-\n", name);
#endif

  /* Do the Scalar output */
  if (CCTK_GroupTypeFromVarI (vindex) == CCTK_SCALAR)
  {
    retval = IOBasic_WriteScalarGS (GH, vindex, name);
  }
  else
  {
    retval = IOBasic_WriteScalarGA (GH, vindex, name);
  }

  if (retval == 0)
  {
    /* Register variable as having Scalar output this iteration */
    myGH->outScalar_last [vindex] = GH->cctk_iteration;
  }

  return (retval);
}
Esempio n. 7
0
 /*@@
   @routine    PUGH_SetupGAGroup
   @date       January 19 2000
   @author     Gabrielle Allen
   @desc
               Set up a group of grid array variables (CCTK_GF or CCTK_ARRAY
               types) on a pGH.
   @enddesc
   @calls      CCTK_VarTypeSize
               PUGH_SetupConnectivity
               PUGH_SetupPGExtras
               PUGH_SetupGArrayGroupComm
               PUGH_SetupGArray

   @var        newGH
   @vdesc      Pointer to PUGH grid hierarchy
   @vtype      pGH *
   @vio        in
   @endvar
   @var        nsize
   @vdesc      size dimensions for variables in this group
   @vtype      int *
   @vio        in
   @endvar
   @var        ghostsize
   @vdesc      ghostsize dimensions for variables in this group
   @vtype      int *
   @vio        in
   @endvar
   @var        gtype
   @vdesc      group type
   @vtype      int
   @vio        in
   @endvar
   @var        vtype
   @vdesc      CCTK data type for variables in this group
   @vtype      int
   @vio        in
   @endvar
   @var        dim
   @vdesc      number of dimensions for variables in this group
   @vtype      int
   @vio        in
   @endvar
   @var        n_variables
   @vdesc      number of variables in this group
   @vtype      int
   @vio        in
   @endvar
   @var        staggercode
   @vdesc      stagger code for variables in this group
   @vtype      int
   @vio        in
   @endvar
   @var        n_timelevels
   @vdesc      number of timelevels in this group
   @vtype      int
   @vio        in
   @endvar
   @var        vectorgroup
   @vdesc      is this a vector group ?
   @vtype      int
   @vio        in
   @endvar

   @returntype int
   @returndesc
               PUGH_SUCCESS (0) if successful, or
               PUGH_ERRORMEMORY (negative) if memory allocation failed
   @endreturndesc
@@*/
static int PUGH_SetupGAGroup (pGH *newGH,
                              int *nsize,
                              int *ghostsize,
                              int  gtype,
                              int  vtype,
                              int  dim,
                              int  n_variables,
                              int  staggercode,
                              int  n_timelevels,
                              int  vectorgroup)
{
  int i;
  int           variable;
  int           var_size;
  int           retval;
  int           level;
  void       ***temp;
  pConnectivity *connectivity;
  pGExtras      *extras;
  pComm         *groupcomm;
  int *perme;
  int *nprocs;


  retval = PUGH_SUCCESS;
  var_size = CCTK_VarTypeSize (vtype);

  if (gtype == CCTK_ARRAY)
  {
    /* Arrays can't (yet) have periodicity and manual setup,
       so initialize them to zero */
    perme = (int *) calloc (dim, sizeof (int));
    nprocs = (int *) calloc (dim, sizeof (int));
    if (! (perme && nprocs))
    {
      CCTK_WARN (0, "Memory allocation error in PUGH_SetupGAGroup");
    }

    /* Check that there are enough grid points in this dimension
     * to make parallelising it worthwhile
     */
    for (i = 0 ; i < dim; i++)
    {
      if (! nprocs[i] && abs (nsize[i]) <= 2*ghostsize[i] + 1)
      {
        nprocs[i] = 1;
      }
    }

    connectivity = PUGH_SetupConnectivity (dim, newGH->nprocs, nprocs, perme);

    extras = PUGH_SetupPGExtras (dim,
                                 perme,
                                 staggercode,
                                 nsize,
                                 ghostsize,
                                 newGH->nprocs,
                                 connectivity->nprocs,
                                 newGH->myproc);

    free (nprocs);
    free (perme);
  }
  else
  {
    /* this is for CCTK_GF variables */
    connectivity = newGH->Connectivity[dim-1];
    extras = newGH->GFExtras[dim-1];
  }

  /* Set up the communication buffer used for all variables within this group.
     Note: only with allocated buffers we can have group communication. */
  if(newGH->commmodel == PUGH_ALLOCATEDBUFFERS)
  {
    groupcomm = PUGH_SetupGArrayGroupComm (newGH,
                                           dim,
                                           newGH->nvariables,
                                           n_variables,
                                           0,
                                           vtype,
                                           extras);
  }
  else
  {
    groupcomm = NULL;
  }

  temp = (void ***) realloc (newGH->variables, (newGH->nvariables+n_variables) *
                             sizeof (void **));

  if(temp)
  {
    newGH->variables = temp;

    for (variable = 0; variable < n_variables; variable++)
    {
      newGH->variables[newGH->nvariables] = (void **) malloc (n_timelevels *
                                                              sizeof (void *));

      if (newGH->variables[newGH->nvariables])
      {
        for (level = 0; level < n_timelevels; level++)
        {
          newGH->variables[newGH->nvariables][level] =
            PUGH_SetupGArray (newGH,
                              extras,
                              connectivity,
                              groupcomm,
                              CCTK_VarName (newGH->nvariables),
                              newGH->nvariables,
                              newGH->narrays,
                              var_size,
                              vtype,
                              staggercode,
                              vectorgroup ? n_variables : 1,
                              variable,
                              variable > 0 ? newGH->variables[newGH->nvariables-variable][level] : NULL);
          newGH->narrays++;
        }
        newGH->nvariables++;
      }
      else
      {
        retval = PUGH_ERRORMEMORY;
        break;
      }
    }
  }
  else
  {
    retval = PUGH_ERRORMEMORY;
  }

  if (retval)
  {
    CCTK_WARN (1, "Memory allocation error in PUGH_SetupGAGroup");
  }

  return (retval);
}