Esempio n. 1
0
void write_curvilinear_mesh(const char *filename, int ub, int *dims,float *pts,
                            int nvars, int *vardim, int *centering,
                            const char * const *varnames, float **vars)
{
    int   i;
    char  str[128];
    int npts = dims[0]*dims[1]*dims[2];
    int ncX = (dims[0] - 1 < 1 ? 1 : dims[0] - 1);
    int ncY = (dims[1] - 1 < 1 ? 1 : dims[1] - 1);
    int ncZ = (dims[2] - 1 < 1 ? 1 : dims[2] - 1);
    int ncells = ncX*ncY*ncZ;

    useBinary = ub;
    open_file(filename);
    write_header();

    write_string("DATASET STRUCTURED_GRID\n");
    sprintf(str, "DIMENSIONS %d %d %d\n", dims[0], dims[1], dims[2]);
    write_string(str);
    sprintf(str, "POINTS %d float\n", npts);
    write_string(str);
    for (i = 0 ; i < 3*npts ; i++)
    {
        write_float(pts[i]);
    }

    write_variables(nvars, vardim, centering, varnames, vars, npts, ncells);

    close_file();
}
Esempio n. 2
0
bool ranking_synthesis_seneschalt::write_input_file(const exprt &e)
{
  assert(e.id()=="and" && e.type()==bool_typet());

  std::ofstream f("seneschal.input");

  exprt e_ext = e;
  replace_mapt rmap;
  std::set<irep_idt> inputs, outputs;

  collect_variables(e_ext, rmap, inputs, outputs);

  // write variable declarations
  write_variables(f, inputs, outputs);
  f << std::endl;

  // translate constraints
  if(!write_constraints(f, rmap, e_ext))
    return false;

  f << std::endl;

  f.close();

  return true;
}
Esempio n. 3
0
void write_unstructured_mesh(const char *filename, int ub, int npts,
                             float *pts, int ncells, int *celltypes, int *conn,
                             int nvars, int *vardim, int *centering,
                             const char * const *varnames, float **vars)
{
    int   i, j;
    char  str[128];
    int   conn_size = 0;
    int  *curr_conn = conn;

    useBinary = ub;
    open_file(filename);
    write_header();

    write_string("DATASET UNSTRUCTURED_GRID\n");
    sprintf(str, "POINTS %d float\n", npts);
    write_string(str);
    for (i = 0 ; i < 3*npts ; i++)
    {
        write_float(pts[i]);
    }

    new_section();
    for (i = 0 ; i < ncells ; i++)
    {
        int npts = num_points_for_cell(celltypes[i]);
         
        conn_size += npts+1;
    }
    sprintf(str, "CELLS %d %d\n", ncells, conn_size);
    write_string(str);
    for (i = 0 ; i < ncells ; i++)
    {
        int npts = num_points_for_cell(celltypes[i]);
        write_int(npts);
        for (j = 0 ; j < npts ; j++)
            write_int(*curr_conn++);
        end_line();
    }

    new_section();
    sprintf(str, "CELL_TYPES %d\n", ncells);
    write_string(str);
    for (i = 0 ; i < ncells ; i++)
    {
        write_int(celltypes[i]);
        end_line();
    }

    write_variables(nvars, vardim, centering, varnames, vars, npts, ncells);

    close_file();
}
Esempio n. 4
0
void write_point_mesh(const char *filename, int ub, int npts, float *pts,
                      int nvars, int *vardim, const char * const *varnames,
                      float **vars)
{
    int   i;
    char  str[128];
    int  *centering = NULL;

    useBinary = ub;
    open_file(filename);
    write_header();

    write_string("DATASET UNSTRUCTURED_GRID\n");
    sprintf(str, "POINTS %d float\n", npts);
    write_string(str);
    for (i = 0 ; i < 3*npts ; i++)
    {
        write_float(pts[i]);
    }

    new_section();
    sprintf(str, "CELLS %d %d\n", npts, 2*npts);
    write_string(str);
    for (i = 0 ; i < npts ; i++)
    {
        write_int(1);
        write_int(i);
        end_line();
    }

    new_section();
    sprintf(str, "CELL_TYPES %d\n", npts);
    write_string(str);
    for (i = 0 ; i < npts ; i++)
    {
        write_int(VISIT_VERTEX);
        end_line();
    }

    centering = (int *) malloc(nvars*sizeof(int));
    for (i = 0 ; i < nvars ; i++)
        centering[i] = 1;
    write_variables(nvars, vardim, centering, varnames, vars, npts, npts);
    free(centering);

    close_file();
}
Esempio n. 5
0
void write_rectilinear_mesh(const char *filename, int ub, int *dims,
                            float *x, float *y, float *z,
                            int nvars, int *vardim, int *centering,
                            const char * const *varnames, float **vars)
{
    int   i;
    char  str[128];
    int npts = dims[0]*dims[1]*dims[2];
    int ncX = (dims[0] - 1 < 1 ? 1 : dims[0] - 1);
    int ncY = (dims[1] - 1 < 1 ? 1 : dims[1] - 1);
    int ncZ = (dims[2] - 1 < 1 ? 1 : dims[2] - 1);
    int ncells = ncX*ncY*ncZ;

    useBinary = ub;
    open_file(filename);
    write_header();

    write_string("DATASET RECTILINEAR_GRID\n");
    sprintf(str, "DIMENSIONS %d %d %d\n", dims[0], dims[1], dims[2]);
    write_string(str);
    sprintf(str, "X_COORDINATES %d float\n", dims[0]);
    write_string(str);
    for (i = 0 ; i < dims[0] ; i++)
        write_float(x[i]);
    new_section();
    sprintf(str, "Y_COORDINATES %d float\n", dims[1]);
    write_string(str);
    for (i = 0 ; i < dims[1] ; i++)
        write_float(y[i]);
    new_section();
    sprintf(str, "Z_COORDINATES %d float\n", dims[2]);
    write_string(str);
    for (i = 0 ; i < dims[2] ; i++)
        write_float(z[i]);

    write_variables(nvars, vardim, centering, varnames, vars, npts, ncells);

    close_file();
}