Ejemplo n.º 1
0
/*@@
   @routine   IOASCII_Choose2D
   @author    Gabrielle Allen
   @date      July 6 2000
   @desc
              Use parameters to choose the 2D slices through the output data. 
   @enddesc

   @calls     CCTK_ParameterQueryTimesSet
              IOUtil_2DPlanes

   @var       GH
   @vdesc     Pointer to CCTK grid hierarchy
   @vtype     cGH *
   @vio       in
   @endvar
 @@*/
void IOASCII_Choose2D (cGH *GH)
{
  DECLARE_CCTK_PARAMETERS
  int i;
  asciiioGH *myGH;                  /* IOASCII extension handle */
  int origin_index[3];              /* Specify output planes by indices */
  CCTK_REAL origin_phys[3];         /* Specify output planes by coordinates */


  GET_SLICE (out2D_xyplane_z, out_xyplane_z, origin_index[0], origin_phys[0]);
  GET_SLICE (out2D_xzplane_y, out_xzplane_y, origin_index[1], origin_phys[1]);
  GET_SLICE (out2D_yzplane_x, out_yzplane_x, origin_index[2], origin_phys[2]);

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

  for (i = 1; i <= CCTK_MaxDim (); i++)
  {
    if (i > 1 && i <= 3)
    {
      IOUtil_2DPlanes (GH, i, origin_index, origin_phys, myGH->sp2xyz[i-1]);
    }
    else
    {
      memset (myGH->sp2xyz[i-1], 0, i * sizeof (myGH->sp2xyz[i-1][0]));
    }
  }
  USE_CCTK_PARAMETERS; }
Ejemplo n.º 2
0
/*@@
   @routine   IOASCII_Choose1D
   @author    Gabrielle Allen
   @date      July 6 2000
   @desc
              Use parameters to choose the 1D slices through the output data. 
   @enddesc

   @calls     CCTK_ParameterQueryTimesSet
              IOUtil_1DLines

   @var       GH
   @vdesc     Pointer to CCTK grid hierarchy
   @vtype     cGH *
   @vio       in
   @endvar
@@*/
void IOASCII_Choose1D (cGH *GH)
{
  DECLARE_CCTK_PARAMETERS
  int i, j;
  asciiioGH *myGH;
  int *origin_index[3];
  CCTK_REAL *origin_phys[3];


  /* allocate arrays for origins */
  origin_phys[0] = (CCTK_REAL *) malloc (3 * 3 * sizeof (CCTK_REAL));
  origin_phys[1] = origin_phys[0] + 3;
  origin_phys[2] = origin_phys[1] + 3;
  origin_index[0] = (int *) malloc (3 * 3 * sizeof (int));
  origin_index[1] = origin_index[0] + 3;
  origin_index[2] = origin_index[1] + 3;

  /* get slice points */
  GET_SLICE (out1D_xline_y, out_xline_y, origin_index[0][1], origin_phys[0][1]);
  GET_SLICE (out1D_xline_z, out_xline_z, origin_index[0][2], origin_phys[0][2]);
  GET_SLICE (out1D_yline_x, out_yline_x, origin_index[1][0], origin_phys[1][0]);
  GET_SLICE (out1D_yline_z, out_yline_z, origin_index[1][2], origin_phys[1][2]);
  GET_SLICE (out1D_zline_x, out_zline_x, origin_index[2][0], origin_phys[2][0]);
  GET_SLICE (out1D_zline_y, out_zline_y, origin_index[2][1], origin_phys[2][1]);

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

  for (i = 1; i <= CCTK_MaxDim (); i++)
  {
    if (i <= 3)
    {
      IOUtil_1DLines (GH, i, origin_index, origin_phys, myGH->spxyz[i-1]);
    }
    else
    {
      for (j = 0; j < i; j++)
      {
        memset (myGH->spxyz[i-1][j], 0, i);
      }
    }
  }

  /* free allocated resources */
  free (origin_phys[0]);
  free (origin_index[0]);
  USE_CCTK_PARAMETERS; }
Ejemplo n.º 3
0
 /*@@
   @routine    CactusDefaultSetupGH
   @date       Tue Sep 29 15:06:22 1998
   @author     Tom Goodale
   @desc
               Default cactus SetupGH routine.
   @enddesc
   @calls      CCTK_MaxDim
               CCTK_NumVars
               CCTK_NumTimeLevelsFromVarI
               CCTK_NumGroups
               CCTKi_SetupGHExtensions

   @var        config
   @vdesc      Pointer to flesh configuration environment
   @vtype      tFleshConfig *
   @vio        in
   @endvar
   @var        convergence_level
   @vdesc      convergence leve of new cGH
   @vtype      int
   @vio        in
   @endvar

   @returntype cGH *
   @returndesc
               the pointer to the new cGH structure,
               or NULL if memory allocation failed
   @endreturndesc
@@*/
cGH *CactusDefaultSetupGH(tFleshConfig *config, int convergence_level)
{
  cGH *thisGH;
  int n_groups;
  int n_variables;
  int variable;
  int ntimelevels;
  int cctk_dim;


  /* Put this in for the moment until parameter stuff is done. */
  if(convergence_level > 0)
  {
    return (NULL);
  }

  /* Initialise this since it is used later and in exceptional
   * circumstances might not be initialsed beforehand.
   */

  variable = -1;

  /* Create a new Grid Hierarchy */
  thisGH = (cGH *)malloc(sizeof(cGH));

  if(thisGH)
  {
    thisGH->cctk_dim = CCTK_MaxDim();

    /* Need this to be at least one otherwise the memory allocation will fail. */
    cctk_dim = thisGH->cctk_dim;
    if(thisGH->cctk_dim == 0) cctk_dim = 1;
    thisGH->cctk_iteration    = 0;
    thisGH->cctk_gsh          = (int *)malloc(cctk_dim*sizeof(int));
    thisGH->cctk_lsh          = (int *)malloc(cctk_dim*sizeof(int));
    thisGH->cctk_lbnd         = (int *)malloc(cctk_dim*sizeof(int));
    thisGH->cctk_ubnd         = (int *)malloc(cctk_dim*sizeof(int));

    thisGH->cctk_lssh         = (int *)malloc(CCTK_NSTAGGER*cctk_dim*sizeof(int));
    thisGH->cctk_to           = (int *)malloc(cctk_dim*sizeof(int));
    thisGH->cctk_from         = (int *)malloc(cctk_dim*sizeof(int));
    thisGH->cctk_bbox         = (int *)malloc(2*cctk_dim*sizeof(int));
    thisGH->cctk_nghostzones  = (int *)malloc(2*cctk_dim*sizeof(int));
    thisGH->cctk_levfac       = (int *)malloc(cctk_dim*sizeof(int));
    thisGH->cctk_delta_space  = (CCTK_REAL *)malloc(cctk_dim*sizeof(CCTK_REAL));
    /* FIXME : Next line goes when coords are done properly */
    thisGH->cctk_origin_space = (CCTK_REAL *)malloc(cctk_dim*sizeof(CCTK_REAL));

    thisGH->cctk_delta_time = 1;
    thisGH->cctk_convlevel = 0;

    n_variables = CCTK_NumVars();

    /* Allocate memory for the variable data pointers.
     * Note we want at least one to prevent memory allocattion from failing !
     */
    thisGH->data = (void ***)malloc((n_variables ? n_variables:1)*sizeof(void **));

    if(thisGH->data)
    {
      for(variable = 0; variable < n_variables; variable++)
      {
        ntimelevels = CCTK_NumTimeLevelsFromVarI(variable);

        thisGH->data[variable] = (void **)calloc(ntimelevels, sizeof(void *));
        if(thisGH->data[variable] == NULL)
        {
          break;
        }
      }
    }

    thisGH->extensions = NULL;

    /* Allocate memory for the group data pointers.
     * Note we want at least one to prevent memory allocattion from failing !
     */
    n_groups = CCTK_NumGroups();
    thisGH->GroupData = (cGHGroupData *)malloc((n_groups ? n_groups:1)*sizeof(cGHGroupData));

  }

  if(thisGH &&
     thisGH->cctk_gsh &&
     thisGH->cctk_lsh &&
     thisGH->cctk_lbnd &&
     thisGH->cctk_ubnd &&
     thisGH->cctk_lssh &&
     thisGH->cctk_from &&
     thisGH->cctk_to &&
     thisGH->cctk_bbox &&
     thisGH->cctk_nghostzones &&
     thisGH->cctk_levfac &&
     thisGH->cctk_delta_space &&
     thisGH->cctk_origin_space &&
     thisGH->data &&
     variable == n_variables &&
     thisGH->GroupData)
  {
    /* Traverse list of GH setup routines. */
    CCTKi_SetupGHExtensions(config, convergence_level, thisGH);
  }
  else
  {
    /* FIXME: should free potentially allocated memory for this GH */
    thisGH = NULL;
  }

  return (thisGH);
}