Ejemplo n.º 1
0
/* ********************************************************************* */
void WriteVTK_Header (FILE *fvtk, Grid *grid)
/*!
 * Write VTK header in parallel or serial mode.
 * In parallel mode only processor 0 does the actual writing 
 * (see al_io.c/AL_Write_header).
 *
 *
 * \param [in]  fvtk  pointer to file
 * \param [in]  grid  pointer to an array of Grid structures
 *
 * \todo  Write the grid using several processors. 
 *********************************************************************** */
{
  int    i, j, k;
  int    nx1, nx2, nx3;
  char   header[1024];
  float  x1, x2, x3;
  static float  ***node_coord, *xnode, *ynode, *znode;

/* ------------------------------------------------
          get global dimensions
   ------------------------------------------------ */

  nx1 = grid[IDIR].gend + 1 - grid[IDIR].nghost;
  nx2 = grid[JDIR].gend + 1 - grid[JDIR].nghost;
  nx3 = grid[KDIR].gend + 1 - grid[KDIR].nghost;

/* -------------------------------------------------------------
     Allocate memory and define node coordinates only once.
   ------------------------------------------------------------- */

  if (node_coord == NULL){
    node_coord = ARRAY_3D(nx2 + JOFFSET, nx1 + IOFFSET, 3, float);

    #if VTK_FORMAT == RECTILINEAR_GRID
     xnode = ARRAY_1D(nx1 + IOFFSET, float);
     ynode = ARRAY_1D(nx2 + JOFFSET, float);
     znode = ARRAY_1D(nx3 + KOFFSET, float);

     for (i = 0; i < nx1 + IOFFSET; i++){
       x1 = (float)(grid[IDIR].xl_glob[i+IBEG]);
       if (IsLittleEndian()) SWAP_VAR(x1);
       xnode[i] = x1;
     }
     for (j = 0; j < nx2 + JOFFSET; j++){
       x2 = (float)(grid[JDIR].xl_glob[j+JBEG]);
       if (IsLittleEndian()) SWAP_VAR(x2);
       ynode[j] = x2;
     }
     for (k = 0; k < nx3 + KOFFSET; k++){
       x3 = (float)(grid[KDIR].xl_glob[k+KBEG]);
       if (IsLittleEndian()) SWAP_VAR(x3);
       #if DIMENSIONS == 2
        znode[k] = 0.0;
       #else
        znode[k] = x3;
       #endif
     }
    #endif
  }
Ejemplo n.º 2
0
void vector_swap(struct vector *a, struct vector *b)
{
	struct vector tmp;

	assert(a);
	assert(b);

	SWAP_VAR(tmp, a, b, element_size);
	SWAP_VAR(tmp, a, b, count);
	SWAP_VAR(tmp, a, b, allocated_count);
	SWAP_VAR(tmp, a, b, data);
	SWAP_VAR(tmp, a, b, destruct);
}