/* Copyright (c) 1994 - 2010, Lawrence Livermore National Security, LLC. LLNL-CODE-425250. All rights reserved. This file is part of Silo. For details, see silo.llnl.gov. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the disclaimer below. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the disclaimer (as noted below) in the documentation and/or other materials provided with the distribution. * Neither the name of the LLNS/LLNL nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This work was produced at Lawrence Livermore National Laboratory under Contract No. DE-AC52-07NA27344 with the DOE. Neither the United States Government nor Lawrence Livermore National Security, LLC nor any of their employees, makes any warranty, express or implied, or assumes any liability or responsibility for the accuracy, completeness, or usefulness of any information, apparatus, product, or process disclosed, or represents that its use would not infringe privately-owned rights. Any reference herein to any specific commercial products, process, or services by trade name, trademark, manufacturer or otherwise does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United States Government or Lawrence Livermore National Security, LLC. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or Lawrence Livermore National Security, LLC, and shall not be used for advertising or product endorsement purposes. */ /* File-wide modifications: * * Sean Ahern, Wed Jan 22 15:11:09 PST 1997 * I reformated whitespace: got rid of tabs and ending whitespace. I * added inclusion of standard include files to get the prototypes for * standard functions. I added prototypes for the functions defined here * and made them static. I changed all function definitions to be ANSI. * I ran the file through "lint" and made appropriate changes. * * Sean Ahern, Mon Oct 12 17:38:36 PDT 1998 * Removed use of the AIO library, since it's no longer supported. * * Sean Ahern, Mon Nov 2 17:59:23 PST 1998 * Removed use of the coordnames in the DBPutQuadmesh and DBPutUcdmesh * calls since the parameter is ignored anyway. * * Eric Brugger, Mon Feb 22 14:21:13 PST 1999 * I changed all floats used for storing intermediate values to doubles * to reduce numeric errors. * */ #include #include #include #include #include #ifndef WIN32 #include #else #include #include #endif #include #include "silo.h" #include #define false 0 #define true 1 #define Min(A,B) (((A)<(B))?(A):(B)) #define Max(A,B) (((A)<(B))?(B):(A)) #ifndef M_PI /* yea, Solaris 5 */ #define M_PI 3.14159265358979323846264338327950288 /* pi */ #endif #define ALLOC_N(x,n) (x *) calloc (n, sizeof (x)) #define FREE(x) if ( (x) != NULL) {free(x);(x)=NULL;} /* Local function prototypes */ static void fill_rect2d_bkgr(int matlist[], int nx, int ny, int matno); static void fill_rect2d_mat(float x[], float y[], int matlist[], int nx, int ny, int mix_next[], int mix_mat[], int mix_zone[], float mix_vf[], int *mixlen, int matno, double radius); static void fill_rect3d_bkgr(int matlist[], int nx, int ny, int nz, int matno); static void fill_rect3d_mat(float x[], float y[], float z[], int matlist[], int nx, int ny, int nz, int mix_next[], int mix_mat[], int mix_zone[], float mix_vf[], int *mixlen, int matno, double radius); static void build_rect2d(DBfile * dbfile, int size, int order); static void build_curv2d(DBfile * dbfile, int size, int order); static void build_ucd2d(DBfile * dbfile, int size, int order); static void build_rect3d(DBfile * dbfile, int size, int order); static void build_curv3d(DBfile * dbfile, int size, int order); static void build_ucd3d(DBfile * dbfile, int size, int order); static void build_poly3d(DBfile * dbfile, int size, int order); static void build_carray(DBfile * dbfile); static void build_curve(DBfile * dbfile, int driver); static void MakeFiles(char *suffix, int size, int order, int type); static void fill_rect2d_bkgr(int matlist[], int nx, int ny, int matno) { int i, j; for (i = 0; i < nx; i++) { for (j = 0; j < ny; j++) { matlist[j * nx + i] = matno; } } } static void fill_rect2d_mat(float x[], float y[], int matlist[], int nx, int ny, int mix_next[], int mix_mat[], int mix_zone[], float mix_vf[], int *mixlen, int matno, double radius) { int i, j, k, l; double xcenter, ycenter; double dist; int cnt; int mixlen2; int *itemp; double dx, dy; double xx[20], yy[20]; mixlen2 = *mixlen; itemp = ALLOC_N (int, (nx + 1) * (ny + 1)); xcenter = .5; ycenter = .5; for (i = 0; i < nx + 1; i++) { for (j = 0; j < ny + 1; j++) { dist = sqrt((x[i] - xcenter) * (x[i] - xcenter) + (y[j] - ycenter) * (y[j] - ycenter)); itemp[j * (nx + 1) + i] = (dist < radius) ? 1 : 0; } } for (i = 0; i < nx; i++) { for (j = 0; j < ny; j++) { cnt = itemp[(j) * (nx + 1) + (i)] + itemp[(j + 1) * (nx + 1) + (i)] + itemp[(j + 1) * (nx + 1) + (i + 1)] + itemp[(j) * (nx + 1) + (i + 1)]; if (cnt == 0) { /* EMPTY */ } else if (cnt == 4) { matlist[j * nx + i] = matno; } else { dx = (x[i + 1] - x[i]) / 21.; dy = (y[j + 1] - y[j]) / 21.; for (k = 0; k < 20; k++) { xx[k] = x[i] + (dx / 2.) + (k * dx); yy[k] = y[j] + (dy / 2.) + (k * dy); } cnt = 0; for (k = 0; k < 20; k++) { for (l = 0; l < 20; l++) { dist = sqrt((xx[k] - xcenter) * (xx[k] - xcenter) + (yy[l] - ycenter) * (yy[l] - ycenter)); cnt += (dist < radius) ? 1 : 0; } } mix_mat[mixlen2] = matlist[j * nx + i]; mix_mat[mixlen2 + 1] = matno; mix_next[mixlen2] = mixlen2 + 2; mix_next[mixlen2 + 1] = 0; mix_zone[mixlen2] = j * nx + i; mix_zone[mixlen2 + 1] = j * nx + i; mix_vf[mixlen2] = 1. - (((double)cnt) / 400.); mix_vf[mixlen2 + 1] = ((double)cnt) / 400.; matlist[j * nx + i] = - (mixlen2 + 1); mixlen2 += 2; } } } FREE (itemp); *mixlen = mixlen2; } static void fill_rect3d_bkgr(int matlist[], int nx, int ny, int nz, int matno) { int i, j, k; for (i = 0; i < nx; i++) { for (j = 0; j < ny; j++) { for (k = 0; k < nz; k++) { matlist[k * nx * ny + j * nx + i] = matno; } } } } static void fill_rect3d_mat(float x[], float y[], float z[], int matlist[], int nx, int ny, int nz, int mix_next[], int mix_mat[], int mix_zone[], float mix_vf[], int *mixlen, int matno, double radius) { int i, j, k, l, m, n; double xcenter, ycenter, zcenter; double dist; int cnt; int mixlen2; int *itemp; double dx, dy, dz; double xx[10], yy[10], zz[10]; mixlen2 = *mixlen; itemp = ALLOC_N (int, (nx + 1) * (ny + 1) * (nz + 1)); xcenter = .5; ycenter = .5; zcenter = .5; for (i = 0; i < nx + 1; i++) { for (j = 0; j < ny + 1; j++) { for (k = 0; k < nz + 1; k++) { dist = sqrt((x[i] - xcenter) * (x[i] - xcenter) + (y[j] - ycenter) * (y[j] - ycenter) + (z[k] - zcenter) * (z[k] - zcenter)); itemp[k * (nx + 1) * (ny + 1) + j * (nx + 1) + i] = (dist < radius) ? 1 : 0; } } } for (i = 0; i < nx; i++) { for (j = 0; j < ny; j++) { for (k = 0; k < nz; k++) { cnt = itemp[(i) * (nx + 1) * (ny + 1) + (j) * (nx + 1) + k] + itemp[(i) * (nx + 1) * (ny + 1) + (j + 1) * (nx + 1) + k] + itemp[(i) * (nx + 1) * (ny + 1) + (j + 1) * (nx + 1) + k + 1] + itemp[(i) * (nx + 1) * (ny + 1) + (j) * (nx + 1) + k + 1] + itemp[(i + 1) * (nx + 1) * (ny + 1) + (j) * (nx + 1) + k] + itemp[(i + 1) * (nx + 1) * (ny + 1) + (j + 1) * (nx + 1) + k] + itemp[(i + 1) * (nx + 1) * (ny + 1) + (j + 1) * (nx + 1) + k + 1] + itemp[(i + 1) * (nx + 1) * (ny + 1) + (j) * (nx + 1) + k + 1]; if (cnt == 0) { /* EMPTY */ } else if (cnt == 8) { matlist[i * nx * ny + j * nx + k] = matno; } else { dx = (x[i + 1] - x[i]) / 11.; dy = (y[j + 1] - y[j]) / 11.; dz = (z[k + 1] - z[k]) / 11.; for (l = 0; l < 10; l++) { xx[l] = x[i] + (dx / 2.) + (l * dx); yy[l] = y[j] + (dy / 2.) + (l * dy); zz[l] = z[k] + (dz / 2.) + (l * dz); } cnt = 0; for (l = 0; l < 10; l++) { for (m = 0; m < 10; m++) { for (n = 0; n < 10; n++) { dist = sqrt((xx[l] - xcenter) * (xx[l] - xcenter) + (yy[m] - ycenter) * (yy[m] - ycenter) + (zz[n] - zcenter) * (zz[n] - zcenter)); cnt += (dist < radius) ? 1 : 0; } } } mix_mat[mixlen2] = matlist[i * nx * ny + j * nx + k]; mix_mat[mixlen2 + 1] = matno; mix_next[mixlen2] = mixlen2 + 2; mix_next[mixlen2 + 1] = 0; mix_zone[mixlen2] = i * nx * ny + j * nx + k; mix_zone[mixlen2 + 1] = i * nx * ny + j * nx + k; mix_vf[mixlen2] = 1. - (((double)cnt) / 1000.); mix_vf[mixlen2 + 1] = ((double)cnt) / 1000.; matlist[i * nx * ny + j * nx + k] = -(mixlen2 + 1); mixlen2 += 2; } } } } FREE (itemp); *mixlen = mixlen2; } /*------------------------------------------------------------------------- * Function: build_rect2d * * Purpose: Builds a rectilinear 2-d mesh and places it in the open * data file. * * Return: Success: void * * Failure: * * Programmer: robb@cloud * Wed Nov 23 10:13:51 EST 1994 * * Modifications: * Sean Ahern, Thu Jun 20 08:53:11 PDT 1996 * Changed the mesh name to be more mnemonic. * * Sean Ahern, Fri Oct 11 17:08:42 PDT 1996 * Changed the mesh name in the _meshtvinfo variable. * * Jim Reus, Wed Nov 13 07:24:24 PST 1996 * Added temperature (t) variable to demonstrate logplots. * ...temperature is positive non-zero, linear in x and * exponential in y. * * Eric Brugger, Tue Nov 26 11:42:47 PST 1996 * I added the outputing of some meshtv defvars to the silo file. * * Sean Ahern, Wed Jan 22 15:16:58 PST 1997 * Initialized some local pointer variables to NULL. Got rid of unused * variables and variables that were being set but not used. * * Robb Matzke, Wed Jun 18 11:02:17 EST 1997 * Added the `ascii' variable to check labeling by ascii value in * meshtvx. * * Eric Brugger, Mon Sep 20 19:10:11 PDT 1999 * I modified the material numbers so that they are no longer * numbered consecutively. * * Sean Ahern, Thu Feb 7 13:49:18 PST 2002 * Added material names. * *-------------------------------------------------------------------------*/ /*ARGSUSED*/ static void build_rect2d(DBfile * dbfile, int size, int order) { int cycle; float time; double dtime; int ndims; int nx, ny; int dims[3], zdims[3]; float *coords[3]; float *x = NULL, *y = NULL; char *meshname = NULL, *var1name = NULL, *var2name = NULL; char *var3name = NULL, *var4name = NULL, *matname = NULL; float *d=NULL, *p=NULL, *u=NULL, *v=NULL, *t=NULL, *distarr=NULL; char *ascii=NULL, *asciiw=NULL; int nmats; int matnos[9]; int *matlist = NULL; int dims2[3]; int mixlen; int *mix_next = NULL, *mix_mat = NULL, *mix_zone = NULL; float *mix_vf = NULL; DBoptlist *optlist = NULL; char **matnames = NULL; char **matcolors = NULL; int one = 1; int i, j; double xave, yave; double xcenter, ycenter; double dist; switch (size) { case 1: nx = 30; ny = 40; break; case 2: nx = 300; ny = 400; break; case 3: nx = 1000; ny = 1200; break; } x = ALLOC_N (float, nx + 1); y = ALLOC_N (float, ny + 1); d = ALLOC_N (float, nx * ny); p = ALLOC_N (float, nx * ny); u = ALLOC_N (float, (nx + 1) * (ny + 1)); v = ALLOC_N (float, (nx + 1) * (ny + 1)); t = ALLOC_N (float, (nx + 1) * (ny + 1)); distarr = ALLOC_N (float, nx * ny); ascii = ALLOC_N (char, nx * ny); asciiw = ALLOC_N (char, nx * ny * 9); matlist = ALLOC_N (int, nx * ny); mix_next = ALLOC_N (int, 40 * ny); mix_mat = ALLOC_N (int, 40 * ny); mix_zone = ALLOC_N (int, 40 * ny); mix_vf = ALLOC_N (float, 40 * ny); /* * Create the mesh. */ meshname = "quadmesh2d"; coords[0] = x; coords[1] = y; ndims = 2; dims[0] = nx + 1; dims[1] = ny + 1; for (i = 0; i < nx + 1; i++) x[i] = i * (1. / nx); for (i = 0; i < ny + 1; i++) y[i] = i * (1. / nx); /* * Create the density and pressure arrays. */ var1name = "d"; var2name = "p"; xcenter = .5; ycenter = .5; zdims[0] = nx; zdims[1] = ny; for (i = 0; i < nx; i++) { for (j = 0; j < ny; j++) { xave = (x[i]+x[i+1]) / 2.0 ; yave = (y[j]+y[j+1]) / 2.0 ; dist = sqrt((xave - xcenter) * (xave - xcenter) + (yave - ycenter) * (yave - ycenter)); d[j * nx + i] = dist; p[j * nx + i] = 1 / (dist + 0.0001); } } /* * Create the velocity component arrays. */ var3name = "u"; var4name = "v"; xcenter = .5001; ycenter = .5001; for (i = 0; i < nx + 1; i++) { for (j = 0; j < ny + 1; j++) { dist = sqrt((x[i] - xcenter) * (x[i] - xcenter) + (y[j] - ycenter) * (y[j] - ycenter)); u[j * (nx + 1) + i] = (x[i] - xcenter) / dist; v[j * (nx + 1) + i] = (y[j] - ycenter) / dist; } } /* * Create the temperature array. */ if (t != NULL) { double a,b,c,d; a = 1.; b = 3.; c = 5.; d = 7.; for (i=0; i<=nx; ++i) { double x; x = i / (double) nx; for (j=0; j<=ny; ++j) { double y; y = j / (double) ny; t[j*(nx+1) + i] = a + b*x + c*exp(d*y); } } } /* * Create the ascii label array. The center of the mesh is labeled * `A' and the furthest from the center is labeled `Z'. */ if (ascii) { double maxdist = 0.0; xcenter = .5; ycenter = .5; for (i=0; imaxdist) maxdist = distarr[j*nx+i]; } } for (i=0; i 40 * ny) { printf ("mixlen = %d\n", mixlen); exit (1); } /* * Write out the variables. */ cycle = 48; time = 4.8; dtime = 4.8; /* * The length includes the terminating NULL character. */ i = 30; DBWrite (dbfile, "_meshtvinfo", "mesh quadmesh2d;pseudocolor d", &i, 1, DB_CHAR); i = 44; DBWrite (dbfile, "_meshtv_defvars", "vel vector {u,v};speed scalar sqrt(u*u+v*v)", &i, 1, DB_CHAR); optlist = DBMakeOptlist(15); DBAddOption(optlist, DBOPT_CYCLE, &cycle); DBAddOption(optlist, DBOPT_TIME, &time); DBAddOption(optlist, DBOPT_DTIME, &dtime); DBAddOption(optlist, DBOPT_XLABEL, "X Axis"); DBAddOption(optlist, DBOPT_YLABEL, "Y Axis"); DBAddOption(optlist, DBOPT_XUNITS, "cm"); DBAddOption(optlist, DBOPT_YUNITS, "cm"); DBAddOption(optlist, DBOPT_ALLOWMAT0, &one); DBAddOption(optlist, DBOPT_MATNAMES, matnames); DBAddOption(optlist, DBOPT_MATCOLORS, matcolors); #if 0 i = DB_COLMAJOR; DBAddOption(optlist, DBOPT_MAJORORDER, &i); #endif DBPutQuadmesh(dbfile, meshname, NULL, coords, dims, ndims, DB_FLOAT, DB_COLLINEAR, optlist); DBPutQuadvar1(dbfile, var1name, meshname, d, zdims, ndims, NULL, 0, DB_FLOAT, DB_ZONECENT, optlist); DBPutQuadvar1(dbfile, var2name, meshname, p, zdims, ndims, NULL, 0, DB_FLOAT, DB_ZONECENT, optlist); DBPutQuadvar1(dbfile, var3name, meshname, u, dims, ndims, NULL, 0, DB_FLOAT, DB_NODECENT, optlist); DBPutQuadvar1(dbfile, var4name, meshname, v, dims, ndims, NULL, 0, DB_FLOAT, DB_NODECENT, optlist); DBPutQuadvar1(dbfile, "t", meshname, t, dims, ndims, NULL, 0, DB_FLOAT, DB_NODECENT, optlist); DBPutMaterial(dbfile, matname, meshname, nmats, matnos, matlist, dims2, ndims, mix_next, mix_mat, mix_zone, mix_vf, mixlen, DB_FLOAT, optlist); if (ascii) { void *arr[9]; char *arrnames[] = {"L0","L1","L2","L3","L4","L5","L6","L7","L8"}; j = true; DBAddOption (optlist, DBOPT_ASCII_LABEL, &j); DBPutQuadvar1(dbfile, "ascii", meshname, ascii, zdims, ndims, NULL, 0, DB_CHAR, DB_ZONECENT, optlist); arr[0] = &asciiw[0*nx*ny]; arr[1] = &asciiw[1*nx*ny]; arr[2] = &asciiw[2*nx*ny]; arr[3] = &asciiw[3*nx*ny]; arr[4] = &asciiw[4*nx*ny]; arr[5] = &asciiw[5*nx*ny]; arr[6] = &asciiw[6*nx*ny]; arr[7] = &asciiw[7*nx*ny]; arr[8] = &asciiw[8*nx*ny]; DBPutQuadvar(dbfile, "asciiw", meshname, 9, (DBCAS_t) arrnames, arr, zdims, ndims, NULL, 0, DB_CHAR, DB_ZONECENT, optlist); } DBFreeOptlist(optlist); /* * Free the temporary storage. */ FREE (x); FREE (y); FREE (d); FREE (p); FREE (u); FREE (v); FREE (t); FREE (distarr); FREE (ascii); FREE (asciiw); FREE (matlist); FREE (mix_next); FREE (mix_mat); FREE (mix_zone); FREE (mix_vf); for(i=0;i 50 * nx * ny) { printf ("mixlen = %d\n", mixlen); exit (1); } /* * Write out the variables. */ cycle = 48; time = 4.8; dtime = 4.8; /* * The length includes the terminating NULL character. */ i = 30; DBWrite (dbfile, "_meshtvinfo", "mesh quadmesh3d;pseudocolor d", &i, 1, DB_CHAR); i = 50; DBWrite (dbfile, "_meshtv_defvars", "vel vector {u,v,w};speed scalar sqrt(u*u+v*v+w*w)", &i, 1, DB_CHAR); optlist = DBMakeOptlist(11); DBAddOption(optlist, DBOPT_CYCLE, &cycle); DBAddOption(optlist, DBOPT_TIME, &time); DBAddOption(optlist, DBOPT_DTIME, &dtime); DBAddOption(optlist, DBOPT_XLABEL, "X Axis"); DBAddOption(optlist, DBOPT_YLABEL, "Y Axis"); DBAddOption(optlist, DBOPT_ZLABEL, "Z Axis"); DBAddOption(optlist, DBOPT_XUNITS, "cm"); DBAddOption(optlist, DBOPT_YUNITS, "cm"); DBAddOption(optlist, DBOPT_ZUNITS, "cm"); DBAddOption(optlist, DBOPT_MATNAMES, matnames); #if 0 i = DB_COLMAJOR; DBAddOption(optlist, DBOPT_MAJORORDER, &i); #endif DBPutQuadmesh(dbfile, meshname, NULL, coords, dims, ndims, DB_FLOAT, DB_COLLINEAR, optlist); #ifndef WIN32 binf = open("rect3dz.bin", O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR); #else binf = open("rect3dz.bin", O_CREAT|O_TRUNC|O_WRONLY, S_IREAD|S_IWRITE); #endif DBPutQuadvar1(dbfile, var1name, meshname, d, zdims, ndims, NULL, 0, DB_FLOAT, DB_ZONECENT, optlist); write(binf, d, zdims[0]*zdims[1]*zdims[2]*sizeof(float)); DBPutQuadvar1(dbfile, var2name, meshname, p, zdims, ndims, NULL, 0, DB_FLOAT, DB_ZONECENT, optlist); write(binf, p, zdims[0]*zdims[1]*zdims[2]*sizeof(float)); close(binf); printf("zsize = nz=%d, ny=%d, nx=%d\n", zdims[2], zdims[1], zdims[0]); #ifndef WIN32 binf = open("rect3dn.bin", O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR); #else binf = open("rect3dn.bin", O_CREAT|O_TRUNC|O_WRONLY, S_IREAD|S_IWRITE); #endif DBPutQuadvar1(dbfile, var3name, meshname, u, dims, ndims, NULL, 0, DB_FLOAT, DB_NODECENT, optlist); write(binf, u, dims[0]*dims[1]*dims[2]*sizeof(float)); DBPutQuadvar1(dbfile, var4name, meshname, v, dims, ndims, NULL, 0, DB_FLOAT, DB_NODECENT, optlist); /*write(binf, v, dims[0]*dims[1]*dims[2]*sizeof(float));*/ DBPutQuadvar1(dbfile, var5name, meshname, w, dims, ndims, NULL, 0, DB_FLOAT, DB_NODECENT, optlist); /*write(binf, w, dims[0]*dims[1]*dims[2]*sizeof(float));*/ #if 0 { int i, j, k; for (k = 0; k < dims[2]; k++) { for (j = 0; j < dims[1]; j++) { for (i = 0; i < dims[0]; i++) { write(binf, &u[k*dims[1]*dims[0]+j*dims[0]+i], sizeof(float)); write(binf, &v[k*dims[1]*dims[0]+j*dims[0]+i], sizeof(float)); write(binf, &w[k*dims[1]*dims[0]+j*dims[0]+i], sizeof(float)); } } } } #endif close(binf); printf("size = nz=%d, ny=%d, nx=%d\n", dims[2], dims[1], dims[0]); if (t != NULL) DBPutQuadvar1(dbfile, "t", meshname, t ,dims, ndims, NULL, 0, DB_FLOAT, DB_NODECENT ,optlist ); DBPutMaterial(dbfile, matname, meshname, nmats, matnos, matlist, dims2, ndims, mix_next, mix_mat, mix_zone, mix_vf, mixlen, DB_FLOAT, optlist); DBFreeOptlist(optlist); /* * Free the temporary storage. */ FREE (x); FREE (y); FREE (z); FREE (d); FREE (p); FREE (u); FREE (v); FREE (w); FREE (t); FREE (matlist); FREE (mix_next); FREE (mix_mat); FREE (mix_zone); FREE (mix_vf); for(i=0;infaces; fshapecnt = fl->nfaces; fshapesize = 4; lfacelist = fl->lnodelist; for (i = 0; i < lfacelist; i++) facelist[i] = fl->nodelist[i]; for (i = 0; i < nfaces; i++) zoneno[i] = fl->zoneno[i]; DBFreeFacelist(fl); /* * Write out the variables. */ cycle = 48; time = 4.8; dtime = 4.8; /* * The length includes the terminating NULL character. */ i = 29; DBWrite (dbfile, "_meshtvinfo", "mesh ucdmesh3d;pseudocolor d", &i, 1, DB_CHAR); i = 50; DBWrite (dbfile, "_meshtv_defvars", "vel vector {u,v,w};speed scalar sqrt(u*u+v*v+w*w)", &i, 1, DB_CHAR); optlist = DBMakeOptlist(12); DBAddOption(optlist, DBOPT_CYCLE, &cycle); DBAddOption(optlist, DBOPT_TIME, &time); DBAddOption(optlist, DBOPT_DTIME, &dtime); DBAddOption(optlist, DBOPT_TOPO_DIM, (void *)&td); DBAddOption(optlist, DBOPT_XLABEL, "X Axis"); DBAddOption(optlist, DBOPT_YLABEL, "Y Axis"); DBAddOption(optlist, DBOPT_ZLABEL, "Z Axis"); DBAddOption(optlist, DBOPT_XUNITS, "cm"); DBAddOption(optlist, DBOPT_YUNITS, "cm"); DBAddOption(optlist, DBOPT_ZUNITS, "cm"); DBAddOption(optlist, DBOPT_MATNAMES, matnames); DBPutFacelist(dbfile, "fl1", nfaces, 3, facelist, lfacelist, 0, zoneno, &fshapesize, &fshapecnt, 1, NULL, NULL, 0); DBSetDeprecateWarnings(0); DBPutZonelist(dbfile, "zl1", nzones, 3, zonelist, lzonelist, 0, &zshapesize, &zshapecnt, 1); DBSetDeprecateWarnings(3); DBPutUcdmesh(dbfile, meshname, 3, NULL, coords, nnodes, nzones, "zl1", "fl1", DB_FLOAT, optlist); vars[0] = d; varnames[0] = var1name; DBPutUcdvar(dbfile, var1name, meshname, 1, (DBCAS_t) varnames, vars, nnodes, NULL, 0, DB_FLOAT, DB_NODECENT, optlist); vars[0] = p; varnames[0] = var2name; DBPutUcdvar(dbfile, var2name, meshname, 1, (DBCAS_t) varnames, vars, nnodes, NULL, 0, DB_FLOAT, DB_NODECENT, optlist); vars[0] = u; varnames[0] = var3name; DBPutUcdvar(dbfile, var3name, meshname, 1, (DBCAS_t) varnames, vars, nnodes, NULL, 0, DB_FLOAT, DB_NODECENT, optlist); vars[0] = v; varnames[0] = var4name; DBPutUcdvar(dbfile, var4name, meshname, 1, (DBCAS_t) varnames, vars, nnodes, NULL, 0, DB_FLOAT, DB_NODECENT, optlist); vars[0] = w; varnames[0] = var5name; DBPutUcdvar(dbfile, var5name, meshname, 1, (DBCAS_t) varnames, vars, nnodes, NULL, 0, DB_FLOAT, DB_NODECENT, optlist); vars[0] = t; varnames[0] = "t"; DBPutUcdvar(dbfile, "t", meshname, 1, (DBCAS_t) varnames, vars, nnodes, NULL, 0, DB_FLOAT, DB_NODECENT, optlist); DBPutMaterial(dbfile, matname, meshname, nmats, matnos, matlist, &nzones, 1, mix_next, mix_mat, mix_zone, mix_vf, mixlen, DB_FLOAT, optlist); DBPutMatspecies(dbfile, "species", matname, nmats, nmatspec, speclist, &nzones, 1, nspecmf, specmf, mix_speclist, mixlen, DB_FLOAT, optlist); vars[0] = (float*) ascii; varnames[0] = var6name; DBAddOption(optlist, DBOPT_ASCII_LABEL, &onvalue); DBPutUcdvar(dbfile, var6name, meshname, 1, (DBCAS_t) varnames, vars, nnodes, NULL, 0, DB_CHAR, DB_NODECENT, optlist); DBFreeOptlist(optlist); /* Free variables */ FREE(t); for(i=0;infaces; nfshapes = fl->nshapes; for (i = 0; i < nfshapes; i++) { fshapecnt[i] = fl->shapecnt[i]; fshapesize[i] = fl->shapesize[i]; } lfacelist = fl->lnodelist; facelist = ALLOC_N (int, lfacelist); for (i = 0; i < lfacelist; i++) facelist[i] = fl->nodelist[i]; zoneno = ALLOC_N (int, nfaces); for (i = 0; i < nfaces; i++) zoneno[i] = fl->zoneno[i]; DBFreeFacelist(fl); /* * Write out the variables. */ cycle = 48; time = 4.8; dtime = 4.8; /* * The length includes the terminating NULL character. */ i = 29; DBWrite (dbfile, "_meshtvinfo", "mesh ucdmesh3d;pseudocolor d", &i, 1, DB_CHAR); i = 50; DBWrite (dbfile, "_meshtv_defvars", "vel vector {u,v,w};speed scalar sqrt(u*u+v*v+w*w)", &i, 1, DB_CHAR); optlist = DBMakeOptlist(11); DBAddOption(optlist, DBOPT_CYCLE, &cycle); DBAddOption(optlist, DBOPT_TIME, &time); DBAddOption(optlist, DBOPT_DTIME, &dtime); DBAddOption(optlist, DBOPT_XLABEL, "X Axis"); DBAddOption(optlist, DBOPT_YLABEL, "Y Axis"); DBAddOption(optlist, DBOPT_ZLABEL, "Z Axis"); DBAddOption(optlist, DBOPT_XUNITS, "cm"); DBAddOption(optlist, DBOPT_YUNITS, "cm"); DBAddOption(optlist, DBOPT_ZUNITS, "cm"); DBAddOption(optlist, DBOPT_MATNAMES, matnames); DBPutFacelist(dbfile, "fl1", nfaces, 3, facelist, lfacelist, 0, zoneno, fshapesize, fshapecnt, nfshapes, NULL, NULL, 0); DBPutZonelist2(dbfile, "zl1", nzones, 3, zonelist, lzonelist, 0, lo_offset, hi_offset, zshapetype, zshapesize, zshapecnt, nzshapes, NULL); DBPutUcdmesh(dbfile, meshname, 3, (DBCAS_t) coordnames, coords, nnodes, nzones, "zl1", "fl1", DB_FLOAT, optlist); vars[0] = d; varnames[0] = var1name; DBPutUcdvar(dbfile, var1name, meshname, 1, (DBCAS_t) varnames, vars, nnodes, NULL, 0, DB_FLOAT, DB_NODECENT, optlist); vars[0] = p; varnames[0] = var2name; DBPutUcdvar(dbfile, var2name, meshname, 1, (DBCAS_t) varnames, vars, nnodes, NULL, 0, DB_FLOAT, DB_NODECENT, optlist); vars[0] = u; varnames[0] = var3name; DBPutUcdvar(dbfile, var3name, meshname, 1, (DBCAS_t) varnames, vars, nnodes, NULL, 0, DB_FLOAT, DB_NODECENT, optlist); vars[0] = v; varnames[0] = var4name; DBPutUcdvar(dbfile, var4name, meshname, 1, (DBCAS_t) varnames, vars, nnodes, NULL, 0, DB_FLOAT, DB_NODECENT, optlist); vars[0] = w; varnames[0] = var5name; DBPutUcdvar(dbfile, var5name, meshname, 1, (DBCAS_t) varnames, vars, nnodes, NULL, 0, DB_FLOAT, DB_NODECENT, optlist); vars[0] = t; varnames[0] = "t"; DBPutUcdvar(dbfile, "t", meshname, 1, (DBCAS_t) varnames, vars, nnodes, NULL, 0, DB_FLOAT, DB_NODECENT, optlist); DBPutMaterial(dbfile, matname, meshname, nmats, matnos, matlist, &nzones, 1, NULL, NULL, NULL, NULL, mixlen, DB_FLOAT, optlist); DBFreeOptlist(optlist); /* * Free the temporary storage. */ FREE (x); FREE (y); FREE (z); FREE (d); FREE (p); FREE (u); FREE (v); FREE (w); FREE (t); FREE (matlist); FREE (zonelist); FREE (facelist); FREE (zoneno); for(i=0;i