void write_ucd3d(DBfile *dbfile) { /* Node coordinates */ float x[] = {0.,2.,2.,0.,0.,2.,2.,0.,0.,2.,2.,0.,1.,2.,4.,4.}; float y[] = {0.,0.,0.,0.,2.,2.,2.,2.,4.,4.,4.,4.,6.,0.,0.,0.}; float z[] = {2.,2.,0.,0.,2.,2.,0.,0.,2.,2.,0.,0.,1.,4.,2.,0.}; float *coords[] = {x, y, z}; /* Connectivity */ int nodelist[] = { 1,2,3,4,5,6,7,8, /* hex, zone 1 */ 5,6,7,8,9,10,11,12, /* hex, zone 2 */ 12,11,10,9,13, /* pyramid, zone 3 */ 2,3,16,15,6,7, /* prism, zone 4 */ 2,15,14,6 /* tet, zone 5 */ }; int lnodelist = sizeof(nodelist) / sizeof(int); /* shape type 1 has 8 nodes (hex) */ /* shape type 2 has 5 nodes (pyramid) */ /* shape type 3 has 6 nodes (prism) */ /* shape type 4 has 4 nodes (tet) */ int shapesize[] = {8,5,6,4}; /* We have 2 hex, 1 pyramid, 1 prism, 1 tet */ int shapecounts[] = {2,1,1,1}; int nshapetypes = 4; int nnodes = 16; int nzones = 5; int ndims = 3; /* Write out connectivity information. */ DBPutZonelist(dbfile, "zonelist", nzones, ndims, nodelist, lnodelist, 1, shapesize, shapecounts, nshapetypes); /* Write an unstructured mesh. */ DBPutUcdmesh(dbfile, "mesh", ndims, NULL, coords, nnodes, nzones, "zonelist", NULL, DB_FLOAT, NULL); }
/* *---*---*--* nodes (5,6,7,8) | |\5/ 3 | | 1 |4*----* nodes (3,4) | |/ 2 | *---*------* nodes(0,1,2) cell 1 quad(0,1,6,5) cell 2 quad(1,2,4,3) cell 3 quad(3,4,8,7) cell 4 tri(1,3,6) cell 5 tri(3,7,6) */ void write_ucd2d(DBfile *dbfile) { /* Node coordinates */ float x[] = {0., 2., 5., 3., 5., 0., 2., 4., 5.}; float y[] = {0., 0., 0., 3., 3., 5., 5., 5., 5.}; float *coords[] = {x, y}; /* Connectivity */ int nodelist[] = { 2,4,7, /* tri zone 1. */ 4,8,7, /* tri zone 2. */ 1,2,7,6, /* quad zone 3. */ 2,3,5,4, /* quad zone 4. */ 4,5,9,8 /* quad zone 5. */ }; int lnodelist = sizeof(nodelist) / sizeof(int); /* shape type 1 has 3 nodes (tri), shape type 2 is quad */ int shapesize[] = {3, 4}; /* We have 2 tris and 3 quads */ int shapecounts[] = {2, 3}; int nshapetypes = 2; int nnodes = 9; int nzones = 5; int ndims = 2; /* Write out connectivity information. */ DBPutZonelist(dbfile, "zonelist", nzones, ndims, nodelist, lnodelist, 1, shapesize, shapecounts, nshapetypes); /* Write an unstructured mesh. */ DBPutUcdmesh(dbfile, "mesh", ndims, NULL, coords, nnodes, nzones, "zonelist", NULL, DB_FLOAT, NULL); }
void write_ucd3d(DBfile *dbfile, const char *meshname, int origin) { /* Node coordinates */ DBoptlist *opt = NULL; char zlname[1024]; float x[] = {0.,2.,2.,0.,0.,2.,2.,0.,0.,2.,2.,0.,1.,2.,4.,4.}; float y[] = {0.,0.,0.,0.,2.,2.,2.,2.,4.,4.,4.,4.,6.,0.,0.,0.}; float z[] = {2.,2.,0.,0.,2.,2.,0.,0.,2.,2.,0.,0.,1.,4.,2.,0.}; float *coords[] = {x, y, z}; /* Connectivity */ int nodelist[] = { 1,2,3,4,5,6,7,8, /* hex, zone 1 */ 5,6,7,8,9,10,11,12, /* hex, zone 2 */ 9,10,11,12,13, /* pyramid, zone 3 */ 2,3,16,15,6,7, /* prism, zone 4 */ 2,15,14,6 /* tet, zone 5 */ }; int lnodelist = sizeof(nodelist) / sizeof(int); /* shape type 1 has 8 nodes (hex) */ /* shape type 2 has 5 nodes (pyramid) */ /* shape type 3 has 6 nodes (prism) */ /* shape type 4 has 4 nodes (tet) */ int shapesize[] = {8,5,6,4}; /* We have 2 hex, 1 pyramid, 1 prism, 1 tet */ int shapecounts[] = {2,1,1,1}; int nshapetypes = 4; int nnodes = 16; int nzones = 5; int ndims = 3; sprintf(zlname, "%s_zonelist", meshname); /* Write out connectivity information. */ DBPutZonelist(dbfile, zlname, nzones, ndims, nodelist, lnodelist, 1, shapesize, shapecounts, nshapetypes); /* Write an unstructured mesh. */ opt = MakeOptList(origin); DBPutUcdmesh(dbfile, meshname, ndims, NULL, coords, nnodes, nzones, zlname, NULL, DB_FLOAT, opt); DBFreeOptlist(opt); }
/*---------------------------------------------------------------------------- * Function: writemesh_ucd2d() * * Inputs: db (DBfile*): the Silo file handle * * Returns: (void) * * Abstract: Write the mesh and variables stored in the global Mesh * to the Silo file as a UCDmesh and UCDvars * * Modifications: *---------------------------------------------------------------------------*/ void writemesh_ucd2d(DBfile *db, int mixc, int reorder) { int nl[5000]; float f1[1000],f2[1000], fm[1000]; int x,y,c; float *coord[2]; int dims[2]; char *cnvar, *czvar; short *snvar, *szvar; int *invar, *izvar; long *lnvar, *lzvar; long long *Lnvar, *Lzvar; float *fnvar, *fzvar; double *dnvar, *dzvar; int lnodelist; int nnodes; int nzones; int shapesize[1]; int shapecnt[1]; int shapetyp[1]; /* do mesh */ c=0; for (x=0;x<mesh.nx;x++) { for (y=0;y<mesh.ny;y++) { f1[c]=mesh.node[x][y].x; f2[c]=mesh.node[x][y].y; if (mesh.node[x][y].c != c) { printf("Node mismatch! mesh.c=%d c=%d\n",mesh.node[x][y].c,c); exit(-1); } c++; } } coord[0]=f1; coord[1]=f2; dims[0]=mesh.nx; dims[1]=mesh.ny; /* create the zonelist */ c=0; for (x=0;x<mesh.zx;x++) { for (y=0;y<mesh.zy;y++) { nl[c++] = mesh.zone[x][y].n[0][0]->c; nl[c++] = mesh.zone[x][y].n[1][0]->c; nl[c++] = mesh.zone[x][y].n[1][1]->c; nl[c++] = mesh.zone[x][y].n[0][1]->c; } } lnodelist=c; nnodes=mesh.nx*mesh.ny; nzones=mesh.zx*mesh.zy; shapesize[0]=4; shapecnt[0]=nzones; shapetyp[0]=DB_ZONETYPE_QUAD; DBPutZonelist2(db,"Mesh_zonelist",nzones,2,nl,lnodelist,0,0,0,shapetyp,shapesize,shapecnt,1,NULL); DBPutUcdmesh (db,"Mesh",2,NULL,coord,nnodes,nzones,"Mesh_zonelist",NULL,DB_FLOAT,NULL); /* test output of ghost node and zone labels */ { int i; char *gn = (char*)calloc(nnodes,1); char *gz = (char*)calloc(nzones,1); DBoptlist *ol = DBMakeOptlist(5); for (i = 0; i < nnodes; i++) { if (!(i % 3)) gn[i] = 1; } for (i = 0; i < nzones; i++) { if (!(i % 7)) gz[i] = 1; } DBAddOption(ol, DBOPT_GHOST_NODE_LABELS, gn); DBPutUcdmesh (db,"Mesh_gn",2,NULL,coord,nnodes,nzones,"Mesh_zonelist",NULL,DB_FLOAT,ol); DBClearOption(ol, DBOPT_GHOST_NODE_LABELS); DBPutUcdmesh (db,"Mesh_gz",2,NULL,coord,nnodes,nzones,"Mesh_zonelist_gz",NULL,DB_FLOAT,NULL); DBAddOption(ol, DBOPT_GHOST_ZONE_LABELS, gz); DBPutZonelist2(db,"Mesh_zonelist_gz",nzones,2,nl,lnodelist,0,0,0,shapetyp,shapesize,shapecnt,1,ol); DBAddOption(ol, DBOPT_GHOST_NODE_LABELS, gn); DBPutUcdmesh (db,"Mesh_gnz",2,NULL,coord,nnodes,nzones,"Mesh_zonelist_gnz",NULL,DB_FLOAT,ol); DBPutZonelist2(db,"Mesh_zonelist_gnz",nzones,2,nl,lnodelist,0,0,0,shapetyp,shapesize,shapecnt,1,ol); DBFreeOptlist(ol); free(gn); free(gz); } /* do Node vars */ cnvar = (char *) malloc(sizeof(char)*nnodes); snvar = (short *) malloc(sizeof(short)*nnodes); invar = (int *) malloc(sizeof(int)*nnodes); lnvar = (long *) malloc(sizeof(long)*nnodes); Lnvar = (long long *) malloc(sizeof(long long)*nnodes); fnvar = (float *) malloc(sizeof(float)*nnodes); dnvar = (double *) malloc(sizeof(double)*nnodes); c=0; for (x=0;x<mesh.nx;x++) { for (y=0;y<mesh.ny;y++) { f1[c]=mesh.node[x][y].vars[NV_U]; f2[c]=mesh.node[x][y].vars[NV_V]; cnvar[c] = (char) (x<y?x:y); snvar[c] = (short) (x<y?x:y); invar[c] = (int) (x<y?x:y); lnvar[c] = (long) (x<y?x:y); Lnvar[c] = (long long) (x<y?x:y); fnvar[c] = (float) (x<y?x:y); dnvar[c] = (double) (x<y?x:y); c++; } } { DBoptlist *opt = DBMakeOptlist(1); int val = DB_ON; DBAddOption(opt,DBOPT_USESPECMF,&val); DBPutUcdvar1(db, "u", "Mesh", f1, nnodes, NULL, 0, DB_FLOAT, DB_NODECENT, opt); DBPutUcdvar1(db, "v", "Mesh", f2, nnodes, NULL, 0, DB_FLOAT, DB_NODECENT, opt); DBPutUcdvar1(db, "u", "Mesh", f1, nnodes, NULL, 0, DB_FLOAT, DB_NODECENT, opt); DBPutUcdvar1(db, "v", "Mesh", f2, nnodes, NULL, 0, DB_FLOAT, DB_NODECENT, opt); DBPutUcdvar1(db, "cnvar", "Mesh", cnvar, nnodes, NULL, 0, DB_CHAR, DB_NODECENT, opt); DBPutUcdvar1(db, "snvar", "Mesh", snvar, nnodes, NULL, 0, DB_SHORT, DB_NODECENT, opt); DBPutUcdvar1(db, "invar", "Mesh", invar, nnodes, NULL, 0, DB_INT, DB_NODECENT, opt); DBPutUcdvar1(db, "lnvar", "Mesh", lnvar, nnodes, NULL, 0, DB_LONG, DB_NODECENT, opt); DBPutUcdvar1(db, "Lnvar", "Mesh", Lnvar, nnodes, NULL, 0, DB_LONG_LONG, DB_NODECENT, opt); DBPutUcdvar1(db, "fnvar", "Mesh", fnvar, nnodes, NULL, 0, DB_FLOAT, DB_NODECENT, opt); DBPutUcdvar1(db, "dnvar", "Mesh", dnvar, nnodes, NULL, 0, DB_DOUBLE, DB_NODECENT, opt); DBFreeOptlist(opt); } free(cnvar); free(snvar); free(invar); free(lnvar); free(Lnvar); free(fnvar); free(dnvar); /* do Zone vars */ dims[0]--; dims[1]--; czvar = (char *) malloc(sizeof(char)*nzones); szvar = (short *) malloc(sizeof(short)*nzones); izvar = (int *) malloc(sizeof(int)*nzones); lzvar = (long *) malloc(sizeof(long)*nzones); Lzvar = (long long *) malloc(sizeof(long long)*nzones); fzvar = (float *) malloc(sizeof(float)*nzones); dzvar = (double *) malloc(sizeof(double)*nzones); c=0; for (x=0;x<mesh.zx;x++) { for (y=0;y<mesh.zy;y++) { f1[c]=mesh.zone[x][y].vars[ZV_P]; f2[c]=mesh.zone[x][y].vars[ZV_D]; czvar[c] = (char) (x<y?x:y); szvar[c] = (short) (x<y?x:y); izvar[c] = (int) (x<y?x:y); lzvar[c] = (long) (x<y?x:y); Lzvar[c] = (long long) (x<y?x:y); fzvar[c] = (float) (x<y?x:y); dzvar[c] = (double) (x<y?x:y); c++; } } for (c=0; c<mixc; c++) fm[c] = 2.0/mixc*c; if (reorder) { float tmp=fm[mixc-1]; fm[mixc-1]=fm[mixc-2]; fm[mixc-2]=tmp; } DBPutUcdvar1(db, "p", "Mesh", f1, nzones, NULL, 0, DB_FLOAT, DB_ZONECENT, NULL); DBPutUcdvar1(db, "d", "Mesh", f2, nzones, fm, mixc, DB_FLOAT, DB_ZONECENT, NULL); DBPutUcdvar1(db, "czvar", "Mesh", czvar, nzones, NULL, 0, DB_CHAR, DB_ZONECENT, NULL); DBPutUcdvar1(db, "szvar", "Mesh", szvar, nzones, NULL, 0, DB_SHORT, DB_ZONECENT, NULL); DBPutUcdvar1(db, "izvar", "Mesh", izvar, nzones, NULL, 0, DB_INT, DB_ZONECENT, NULL); DBPutUcdvar1(db, "lzvar", "Mesh", lzvar, nzones, NULL, 0, DB_LONG, DB_ZONECENT, NULL); DBPutUcdvar1(db, "Lzvar", "Mesh", Lzvar, nzones, NULL, 0, DB_LONG_LONG, DB_ZONECENT, NULL); DBPutUcdvar1(db, "fzvar", "Mesh", fzvar, nzones, NULL, 0, DB_FLOAT, DB_ZONECENT, NULL); DBPutUcdvar1(db, "dzvar", "Mesh", dzvar, nzones, NULL, 0, DB_DOUBLE, DB_ZONECENT, NULL); free(czvar); free(szvar); free(izvar); free(lzvar); free(Lzvar); free(fzvar); free(dzvar); }
bool SpeckleyElements::writeToSilo(DBfile* dbfile, const string& siloPath, const StringVec& labels, const StringVec& units, bool writeMeshData) { #ifdef ESYS_HAVE_SILO if (numElements == 0) return true; int ret; if (siloPath != "") { ret = DBSetDir(dbfile, siloPath.c_str()); if (ret != 0) return false; } // write out the full mesh in any case nodeMesh->setSiloPath(siloPath); string siloMeshNameStr = nodeMesh->getFullSiloName(); const char* siloMeshName = siloMeshNameStr.c_str(); int arraylen = numElements * nodesPerElement; int eltype = toSiloElementType(type); string varName = name + string("_zones"); ret = DBPutZonelist2(dbfile, varName.c_str(), numElements, nodeMesh->getNumDims(), &nodes[0], arraylen, 0, 0, numGhostElements, &eltype, &nodesPerElement, &numElements, 1, NULL); if (ret == 0) { CoordArray& coordbase = const_cast<CoordArray&>(nodeMesh->getCoords()); DBoptlist* optList = NULL; int nOpts = labels.size()+units.size(); if (nOpts>0) { optList = DBMakeOptlist(nOpts); if (labels.size()>0) DBAddOption(optList, DBOPT_XLABEL, (void*)labels[0].c_str()); if (labels.size()>1) DBAddOption(optList, DBOPT_YLABEL, (void*)labels[1].c_str()); if (labels.size()>2) DBAddOption(optList, DBOPT_ZLABEL, (void*)labels[2].c_str()); if (units.size()>0) DBAddOption(optList, DBOPT_XUNITS, (void*)units[0].c_str()); if (units.size()>1) DBAddOption(optList, DBOPT_YUNITS, (void*)units[1].c_str()); if (units.size()>2) DBAddOption(optList, DBOPT_ZUNITS, (void*)units[2].c_str()); } ret = DBPutUcdmesh(dbfile, siloMeshName, nodeMesh->getNumDims(), NULL, &coordbase[0], nodeMesh->getNumNodes(), numElements, varName.c_str(), /*"facelist"*/NULL, DB_FLOAT, optList); if (optList) DBFreeOptlist(optList); } if (ret != 0) return false; // write out the element-centered variables if enabled if (writeMeshData) { varName = name + string("_Id"); ret = DBPutUcdvar1(dbfile, varName.c_str(), siloMeshName, (float*)&ID[0], numElements, NULL, 0, DB_INT, DB_ZONECENT, NULL); if (ret == 0) { varName = name + string("_Owner"); ret = DBPutUcdvar1(dbfile, varName.c_str(), siloMeshName, (float*)&owner[0], numElements, NULL, 0, DB_INT, DB_ZONECENT, NULL); } } // "Elements" is a special case if (writeMeshData && name == "Elements") { nodeMesh->writeToSilo(dbfile); } return (ret == 0); #else // !ESYS_HAVE_SILO return false; #endif }
/*---------------------------------------------------------------------- * Routine build_ucd_tri * * Purpose * * Build triangle based ucd-mesh and ucd-var, facelist and * zonelist, and return the mesh ID. * * Arguments * name Name to assign mesh. * * Modifications * * Lisa J. Roberts, Fri Apr 7 09:35:52 PDT 2000 * Changed the prototype to ANSI standard and explicitly indicated * the function returns an int. Got rid of flid, zlid, varid, i, * dbid, dims, nmats, maxmix, nftypes, and matid, which were unused. * *--------------------------------------------------------------------*/ int build_ucd_tri(DBfile *dbfile, char *name) { int nzones = 6; int nfaces = 6; int nnodes = 7; int nzshapes = 1; int nfshapes = 1; int lznodelist = 18; int lfnodelist = 12; /*---------------------------------------------------------------------- The test mesh looks like this: 4. | 1 | 3. | 2 6 | 2. | 0 | 1. | 3 5 | | 4 0. --------------------------- 0. 2. 4. *---------------------------------------------------------------------*/ int meshid; static float x[] = {13., 13., 11., 11., 13., 15., 15.}; static float y[] = {2., 4., 3., 1., 0., 1., 3.}; static float u[] = {0., .5, 1., 1.5, 2., 2.5, 3.}; static float d[] = {1., 2., 3., 4., 5., 6.}; static int fnodelist[] = {1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 1}; static int znodelist[] = {0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 5, 0, 5, 6, 0, 6, 1}; int fshapesize, fshapecnt, zshapesize, zshapecnt; int idatatype; #if 0 double ttime = 2.345; int tcycle = 200; int mixlen = MAXMIX; #endif float *coords[3], *vars[1]; char *coordnames[3], *varnames[1]; fshapesize = 2; fshapecnt = nfaces; zshapesize = 3; zshapecnt = nzones; idatatype = DB_FLOAT; coords[0] = x; coords[1] = y; coordnames[0] = "X"; coordnames[1] = "Y"; vars[0] = d; varnames[0] = "d"; (void)DBPutFacelist(dbfile, "fl", nfaces, 2, fnodelist, lfnodelist, 0, NULL, &fshapesize, &fshapecnt, nfshapes, NULL, NULL, 0); (void)DBPutZonelist(dbfile, "zl", nzones, 2, znodelist, lznodelist, 0, &zshapesize, &zshapecnt, nzshapes); meshid = DBPutUcdmesh(dbfile, name, 2, coordnames, coords, nnodes, nzones, "zl", "fl", DB_FLOAT, NULL); vars[0] = d; varnames[0] = "d"; (void)DBPutUcdvar(dbfile, varnames[0], name, 1, varnames, vars, nzones, NULL, 0, idatatype, DB_ZONECENT, NULL); vars[0] = u; varnames[0] = "u"; (void)DBPutUcdvar(dbfile, varnames[0], name, 1, varnames, vars, nnodes, NULL, 0, idatatype, DB_NODECENT, NULL); return (meshid); }
/*---------------------------------------------------------------------- * Routine build_ucd3 * * Purpose * * Build in 3D a ucd-mesh, ucd-var, facelist and zonelist, and return * the mesh ID. * * Arguments * name Name to assign mesh. * * Modifications * * Lisa J. Roberts, Fri Apr 7 09:35:52 PDT 2000 * Changed the prototype to ANSI standard and explicitly indicated * the function returns an int. Got rid of flid, zlid, varid, i, * dfnew, dbid, ln, and matid, which were unused. * *--------------------------------------------------------------------*/ int build_ucd3(DBfile *dbfile, char *name) { #undef NZONES #define NZONES 3 #undef NFACES #define NFACES 14 #undef NNODES #define NNODES 16 #undef MAXMIX #define MAXMIX 12 #undef MAXOMIX #define MAXOMIX 4 #undef NZSHAPES #define NZSHAPES 1 #undef NFSHAPES #define NFSHAPES 1 #undef NFTYPES #define NFTYPES 0 #undef LZNODELIST #define LZNODELIST 24 #undef LFNODELIST #define LFNODELIST 56 /*---------------------------------------------------------------------- The test mesh looks like this: *---------------------------------------------------------------------*/ int meshid; static float x[NNODES] = {0., 1., 1., 0., 0., 1., 1., 0., 0., 1., 1., 0., 0., 1., 1., 0.}; static float y[NNODES] = {0., 0., 0., 0., 1., 1., 1., 1., 2., 2., 2., 2., 3., 3., 3., 3.}; static float z[NNODES] = {0., 0., 1., 1., 0., 0., 1., 1., 0., 0., 1., 1., 0., 0., 1., 1.}; static float u[NNODES] = {0., 0., 0., 0., .1, .1, .1, .1, .2, .2, .2, .2, .3, .3, .3, .3}; static float v[NNODES] = {0., 0., 0., 0., .1, .1, .1, .1, .2, .2, .2, .2, .3, .3, .3, .3}; static float w[NNODES] = {0., 0., 0., 0., .1, .1, .1, .1, .2, .2, .2, .2, .3, .3, .3, .3}; static float d[NZONES] = {2., 4., 6.}; #if 0 static float df[MAXOMIX] = {.58, .78, .42, .22}; static float vf[MAXOMIX] = {.4, .45, .6, .55}; #endif static int matlist[NZONES] = {1, 1, 2}; static int matnos[2] = {1, 2}; #if 0 static int fzoneno[NFACES]; static int fnodelist[LFNODELIST] = {0, 1, 5, 4, 1, 2, 6, 5, 3, 2, 7, 6, 3, 0, 4, 7, 4, 5, 9, 8, 6, 5, 9, 10, 7, 6, 10, 11, 4, 7, 11, 8, 8, 9, 13, 12, 10, 9, 13, 14, 11, 10, 14, 15, 11, 15, 12, 8, 0, 1, 2, 3, 12, 13, 14, 15}; #endif static int znodelist[LZNODELIST] = {0, 1, 2, 3, 4, 5, 6, 7, 4, 5, 6, 7, 8, 9, 10, 11, 8, 9, 10, 11, 12, 13, 14, 15}; #if 0 int fshapesize, fshapecnt; #endif int zshapesize, zshapecnt; int idatatype; int dims; #if 0 double ttime = 2.345; int tcycle = 200; int mixlen = MAXMIX; #endif float *coords[3], *vars[3]; char *coordnames[3], *varnames[3]; DBfacelist *fl; #if 0 int inode, iface, izone, ifl, izl; int nface = 0; #endif int inode, izone, izl; #if 0 fshapesize = 4; fshapecnt = NFACES; #endif zshapesize = 8; zshapecnt = NZONES; idatatype = DB_FLOAT; dims = NZONES; coords[0] = x; coords[1] = y; coords[2] = z; coordnames[0] = "X"; coordnames[1] = "Y"; coordnames[2] = "Z"; vars[0] = d; varnames[0] = "d"; inode = 0; for (izone = 0; izone == NZONES; izone++) { x[inode++] = 0.; x[inode++] = 1.; x[inode++] = 1.; x[inode++] = 0.; inode -= 4; y[inode++] = (float)izone; y[inode++] = (float)izone; y[inode++] = (float)izone; y[inode++] = (float)izone; inode -= 4; z[inode++] = 0.; z[inode++] = 0.; z[inode++] = 1.; z[inode++] = 1.; } izl = 0; for (izone = 0; izone < NZONES; izone++) { for (inode = 0; inode < 4; inode++) { znodelist[izl++] = izone * 4 + inode; } for (inode = 0; inode < 4; inode++) { znodelist[izl++] = (izone + 1) * 4 + inode; } } #if 0 ifl = 0; for (izone = 0; izone < NZONES; izone++) { for (iface = 0; iface < 3; iface++) { fnodelist[ifl++] = izone * 4 + iface; fnodelist[ifl++] = izone * 4 + iface + 1; fnodelist[ifl++] = izone * 4 + iface + 5; fnodelist[ifl++] = izone * 4 + iface + 4; } fnodelist[ifl++] = izone * 4 + 3; fnodelist[ifl++] = izone * 4; fnodelist[ifl++] = izone * 4 + 4; fnodelist[ifl++] = izone * 4 + 7; for (iface = 0; iface < 4; iface++) fzoneno[nface++] = izone; } fnodelist[ifl++] = 0; fnodelist[ifl++] = 1; fnodelist[ifl++] = 2; fnodelist[ifl++] = 3; fzoneno[nface++] = 0; fnodelist[ifl++] = 12; fnodelist[ifl++] = 13; fnodelist[ifl++] = 14; fnodelist[ifl++] = 15; fzoneno[nface++] = NZONES - 1; #endif /* Last parameter was added by Sean Ahern - * Tue Aug 30 17:55:22 PDT 1994 * It is the boundary method. Arbitraryily chosen as 0 */ fl = (DBfacelist *) DBCalcExternalFacelist(znodelist, NNODES, 1, &zshapesize, &zshapecnt, NZSHAPES, matlist, 0); (void)DBPutFacelist(dbfile, "fl", fl->nfaces, 3, fl->nodelist, fl->lnodelist, 0, fl->zoneno, fl->shapesize, fl->shapecnt, fl->nshapes, NULL, NULL, 0); /* * flid = DBPutFacelist (dbfile, "fl", NFACES, 3, fnodelist, LFNODELIST, 0, * fzoneno, &fshapesize, &fshapecnt, NFSHAPES, * NULL, NULL, 0); */ (void)DBPutZonelist(dbfile, "zl", NZONES, 3, znodelist, LZNODELIST, 0, &zshapesize, &zshapecnt, NZSHAPES); meshid = DBPutUcdmesh(dbfile, name, 3, coordnames, coords, NNODES, NZONES, "zl", "fl", DB_FLOAT, NULL); (void)DBPutMaterial(dbfile, "material", name, 2, matnos, matlist, &dims, 1, NULL, NULL, NULL, NULL, 0, DB_FLOAT, NULL); vars[0] = d; varnames[0] = "d"; (void)DBPutUcdvar(dbfile, varnames[0], name, 1, varnames, vars, NZONES, NULL, 0, idatatype, DB_ZONECENT, NULL); vars[0] = u; varnames[0] = "u"; (void)DBPutUcdvar(dbfile, varnames[0], name, 1, varnames, vars, NNODES, NULL, 0, idatatype, DB_NODECENT, NULL); vars[0] = v; varnames[0] = "v"; (void)DBPutUcdvar(dbfile, varnames[0], name, 1, varnames, vars, NNODES, NULL, 0, idatatype, DB_NODECENT, NULL); vars[0] = w; varnames[0] = "w"; (void)DBPutUcdvar(dbfile, varnames[0], name, 1, varnames, vars, NNODES, NULL, 0, idatatype, DB_NODECENT, NULL); vars[0] = u; varnames[0] = "ucomp"; vars[1] = v; varnames[1] = "vcomp"; vars[2] = w; varnames[2] = "wcomp"; (void)DBPutUcdvar(dbfile, "velocity", name, 3, varnames, vars, NNODES, NULL, 0, idatatype, DB_NODECENT, NULL); return (meshid); }
/*---------------------------------------------------------------------- * Routine build_ucd * * Purpose * * Build ucd-mesh, ucd-var, facelist and zonelist, and return * the mesh ID. * * Arguments * name Name to assign mesh. * * Modifications * * Lisa J. Roberts, Fri Apr 7 09:35:52 PDT 2000 * Changed the prototype to ANSI standard and explicitly indicated * the function returns an int. Got rid of flid, zlid, varid, i, * dfnew, dbid, and matid, which were unused. * *--------------------------------------------------------------------*/ int build_ucd(DBfile *dbfile, char *name) { #define NMATS 2 #define NZONES 6 #define NFACES 10 #define NNODES 12 #define MAXMIX 12 #define MAXOMIX 4 #define NZSHAPES 1 #define NFSHAPES 1 #define NFTYPES 0 #define LZNODELIST 24 #define LFNODELIST 20 /*---------------------------------------------------------------------- The test mesh looks like this: 3. | 0 4 8 | 2. | 1 5 9 | 1. | 2 6 10 | | 3 7 11 0. --------------------------- 0. .5 1. *---------------------------------------------------------------------*/ int meshid; /* Default model for material data */ static int matlist[NZONES] = {1, -1, 2, 1, -3, 2}; static int matnos[NMATS] = {1, 2}; static float mix_vf[MAXMIX] = {.6, .8, .4, .2}; static int mix_next[MAXMIX] = {2, 0, 4, 0}; static int mix_mat[MAXMIX] = {1, 2, 1, 2}; static int mix_zone[MAXMIX] = {0, 0, 3, 3}; /* OTHER model for material data */ #if 0 static int imatlist[NZONES] = {1, 0, 2, 1, 0, 2}; static int nmix[NMATS] = {2, 2}; static int mixedels[MAXMIX] = {1, 4, 1, 4}; #endif static float x[NNODES] = {9., 9., 9., 9., 10., 10., 10., 10., 11., 11., 11., 11.}; static float y[NNODES] = {3., 2., 1., 0., 3., 2., 1., 0., 3., 2., 1., 0.}; static float u[NNODES] = {0., .5, 1., 0., .5, 1., 0., .5, 1., 0., .5, 1.}; static float v[NNODES] = {0., .5, 1., 0., .5, 1., 0., .5, 1., 0., .5, 1.}; static float d[NZONES] = {2., 4., 6., 8., 10., 12.}; #if 0 static float df[MAXOMIX] = {.58, .78, .42, .22}; static float vf[MAXOMIX] = {.4, .45, .6, .55}; #endif static int fnodelist[LFNODELIST] = {0, 1, 1, 2, 2, 3, 3, 7, 7, 11, 11, 10, 10, 9, 9, 8, 8, 4, 4, 0}; static int znodelist[LZNODELIST] = {0, 1, 5, 4, 4, 5, 9, 8, 1, 2, 6, 5, 5, 6, 10, 9, 2, 3, 7, 6, 6, 7, 11, 10}; int fshapesize, fshapecnt, zshapesize, zshapecnt; int idatatype, mixlen; int dims; #if 0 double ttime = 2.345; int tcycle = 200; #endif float *coords[3], *vars[2]; char *coordnames[3], *varnames[2]; fshapesize = 2; fshapecnt = NFACES; zshapesize = 4; zshapecnt = NZONES; idatatype = DB_FLOAT; mixlen = MAXMIX; coords[0] = x; coords[1] = y; coordnames[0] = "X"; coordnames[1] = "Y"; vars[0] = d; varnames[0] = "d"; (void)DBPutFacelist(dbfile, "fl", NFACES, 2, fnodelist, LFNODELIST, 0, NULL, &fshapesize, &fshapecnt, NFSHAPES, NULL, NULL, 0); (void)DBPutZonelist(dbfile, "zl", NZONES, 2, znodelist, LZNODELIST, 0, &zshapesize, &zshapecnt, NZSHAPES); meshid = DBPutUcdmesh(dbfile, name, 2, coordnames, coords, NNODES, NZONES, "zl", "fl", DB_FLOAT, NULL); vars[0] = d; varnames[0] = "d"; (void)DBPutUcdvar(dbfile, varnames[0], name, 1, varnames, vars, NZONES, NULL, 0, idatatype, DB_ZONECENT, NULL); vars[0] = u; varnames[0] = "u"; (void)DBPutUcdvar(dbfile, varnames[0], name, 1, varnames, vars, NNODES, NULL, 0, idatatype, DB_NODECENT, NULL); vars[0] = v; varnames[0] = "v"; (void)DBPutUcdvar(dbfile, varnames[0], name, 1, varnames, vars, NNODES, NULL, 0, idatatype, DB_NODECENT, NULL); vars[0] = u; varnames[0] = "ucomp"; vars[1] = v; varnames[1] = "vcomp"; (void)DBPutUcdvar(dbfile, "velocity", name, 2, varnames, vars, NNODES, NULL, 0, idatatype, DB_NODECENT, NULL); dims = NZONES; (void)DBPutMaterial(dbfile, "material", name, NMATS, matnos, matlist, &dims, 1, mix_next, mix_mat, mix_zone, mix_vf, mixlen, DB_FLOAT, NULL); #if 0 mixlen = -99; for (i = 0; i < MAXMIX; i++) { mix_mat[i] = -99; mix_next[i] = -99; mix_zone[i] = -99; mix_vf[i] = -99.; } DBConvertMat(NMATS, NZONES, nmix, mixedels, imatlist, matnos, vf, DB_FLOAT, &mixlen, matlist, mix_next, mix_mat, mix_zone, mix_vf); (void)DBPutMaterial(dbfile, "material", name, matnos, NMATS, matlist, &dims, 1, mix_next, mix_mat, mix_zone, mix_vf, mixlen, DB_FLOAT, NULL); #endif return (meshid); }
int main(int argc, char *argv[]) { int nnodes = NNODES; int nzones = NZONES; int nodelist[23]; int shapesize[] = {8, 4, 5, 6}; int shapecnt[] = {1, 1, 1, 1}; char mesh_command[256]; int len; char *filename = "alltypes.silo"; int driver = DB_PDB; DBfile *dbfile = NULL; int ndims = NDIMS; int dims[NDIMS]; double *coords[NDIMS]; double x[NNODES]; double y[NNODES]; double z[NNODES]; DBfacelist *facelist = NULL; double nodal[NNODES]; double zonal[NZONES]; int matlist[NZONES]; int mats[] = {1,2,3,4}; int i,j; const int origin = 0; int show_all_errors = FALSE; /* Parse command-line options */ for (i=1; i<argc; i++) { if (!strncmp(argv[i], "DB_PDB",6)) { driver = StringToDriver(argv[i]); filename = "alltypes.pdb"; } else if (!strncmp(argv[i], "DB_HDF5", 7)) { driver = StringToDriver(argv[i]); filename = "alltypes.h5"; } else if (!strcmp(argv[i], "show-all-errors")) { show_all_errors = 1; } else if (argv[i][0] != '\0') { fprintf(stderr, "unknown option: %s\n", argv[i]); exit(1); } } /* Turn on error handling */ DBShowErrors(show_all_errors?DB_ALL_AND_DRVR:DB_ABORT, NULL); DBSetFriendlyHDF5Names(2); /* Create file */ printf("Creating test file \"%s\".\n", filename); dbfile = DBCreate(filename, DB_CLOBBER, DB_LOCAL, "3D ucd", driver); i = 0; /* 0 */ x[i] = 0.5; y[i] = 1.0; z[i++] = 0.0; /* 1 */ x[i] = 1.5; y[i] = 1.0; z[i++] = 0.0; /* 2 */ x[i] = 1.5; y[i] = 1.0; z[i++] = 1.0; /* 3 */ x[i] = 0.5; y[i] = 1.0; z[i++] = 1.0; /* 4 */ x[i] = 0.5; y[i] = 2.0; z[i++] = 0.0; /* 5 */ x[i] = 1.5; y[i] = 2.0; z[i++] = 0.0; /* 6 */ x[i] = 2.5; y[i] = 2.0; z[i++] = 0.0; /* 7 */ x[i] = 2.5; y[i] = 2.0; z[i++] = 1.0; /* 8 */ x[i] = 1.5; y[i] = 2.0; z[i++] = 1.0; /* 9 */ x[i] = 0.5; y[i] = 2.0; z[i++] = 1.0; /* 10 */ x[i] = 0.0; y[i] = 3.0; z[i++] = 0.5; /* 11 */ x[i] = 1.0; y[i] = 3.0; z[i++] = 0.5; /* 12 */ x[i] = 2.0; y[i] = 3.0; z[i++] = 0.5; coords[0] = x; coords[1] = y; coords[2] = z; DBPutUcdmesh(dbfile, "mesh", 3, NULL, (void *)coords, nnodes, nzones, "zonelist", "facelist", DB_DOUBLE, NULL); i = 0; /* Hex */ nodelist[i++] = 4; nodelist[i++] = 5; nodelist[i++] = 8; nodelist[i++] = 9; nodelist[i++] = 0; nodelist[i++] = 1; nodelist[i++] = 2; nodelist[i++] = 3; /* Tet */ nodelist[i++] = 10; nodelist[i++] = 4; nodelist[i++] = 11; nodelist[i++] = 9; /* Pyramid */ nodelist[i++] = 4; nodelist[i++] = 5; nodelist[i++] = 8; nodelist[i++] = 9; nodelist[i++] = 11; /* Prism */ nodelist[i++] = 5; nodelist[i++] = 6; nodelist[i++] = 7; nodelist[i++] = 8; nodelist[i++] = 11; nodelist[i++] = 12; for (j=0; j<i; j++) nodelist[j] += origin; DBSetDeprecateWarnings(0); DBPutZonelist(dbfile, "zonelist", nzones, ndims, nodelist, 23, origin, shapesize, shapecnt, 4); DBSetDeprecateWarnings(3); facelist = DBCalcExternalFacelist(nodelist, nnodes, origin, shapesize, shapecnt, 4, NULL, 0); DBPutFacelist(dbfile, "facelist", facelist->nfaces, facelist->ndims, facelist->nodelist, facelist->lnodelist, facelist->origin, facelist->zoneno, facelist->shapesize, facelist->shapecnt, facelist->nshapes, facelist->types, facelist->typelist, facelist->ntypes); for(i=0;i<nnodes;i++) nodal[i] = x[i]; zonal[0] = 4.0; zonal[1] = 2.0; zonal[2] = 0.0; zonal[3] = 7.0; DBPutUcdvar1(dbfile, "nodal", "mesh", (void*)nodal, nnodes, NULL, 0, DB_DOUBLE, DB_NODECENT, NULL); DBPutUcdvar1(dbfile, "zonal", "mesh", (void*)zonal, nzones, NULL, 0, DB_DOUBLE, DB_ZONECENT, NULL); matlist[0] = 1; matlist[1] = 2; matlist[2] = 3; matlist[3] = 4; dims[0] = nzones; DBPutMaterial(dbfile, "mat", "mesh", 4, mats, matlist, dims, 1, NULL, NULL, NULL, NULL, 0, DB_DOUBLE, NULL); sprintf(mesh_command, "mesh mesh"); len = strlen(mesh_command) + 1; DBWrite(dbfile, "_meshtvinfo", mesh_command, &len, 1, DB_CHAR); DBClose(dbfile); DBFreeFacelist(facelist); CleanupDriverStuff(); return 0; }
void grid::output(const output_list_type& olists, std::string _filename, real _t, int cycle, bool analytic) { #ifdef DO_OUTPUT std::thread( [&](const std::string& filename, real t) { printf( "t = %e\n", t); const std::set<node_point>& node_list = olists.nodes; const std::vector<zone_int_type>& zone_list = olists.zones; const int nzones = zone_list.size() / NVERTEX; std::vector<int> zone_nodes; zone_nodes = std::move(zone_list); const int nnodes = node_list.size(); std::vector<double> x_coord(nnodes); std::vector<double> y_coord(nnodes); std::vector<double> z_coord(nnodes); std::array<double*, NDIM> node_coords = {x_coord.data(), y_coord.data(), z_coord.data()}; for (auto iter = node_list.begin(); iter != node_list.end(); ++iter) { const integer i = iter->index; x_coord[i] = iter->pt[0]; y_coord[i] = iter->pt[1]; z_coord[i] = iter->pt[2]; } constexpr int nshapes = 1; int shapesize[1] = {NVERTEX}; int shapetype[1] = {DB_ZONETYPE_HEX}; int shapecnt[1] = {nzones}; const char* coord_names[NDIM] = {"x", "y", "z"}; #ifndef __MIC__ auto olist = DBMakeOptlist(1); double time = double(t); int ndim = 3; DBAddOption(olist, DBOPT_CYCLE, &cycle); DBAddOption(olist, DBOPT_DTIME, &time); DBAddOption(olist, DBOPT_NSPACE, &ndim ); DBfile *db = DBCreateReal(filename.c_str(), DB_CLOBBER, DB_LOCAL, "Euler Mesh", DB_PDB); assert(db); DBPutZonelist2(db, "zones", nzones, int(NDIM), zone_nodes.data(), nzones * NVERTEX, 0, 0, 0, shapetype, shapesize, shapecnt, nshapes, olist); DBPutUcdmesh(db, "mesh", int(NDIM), const_cast<char**>(coord_names), node_coords.data(), nnodes, nzones, "zones", nullptr, DB_DOUBLE, olist); const char* analytic_names[] = {"rho_a", "egas_a", "sx_a", "sy_a", "sz_a", "tau_a"}; DBFreeOptlist(olist); for (int field = 0; field != NF + NGF + NPF; ++field) { auto olist = DBMakeOptlist(1); double time = double(t); int istrue = 1; int isfalse = 0; DBAddOption(olist, DBOPT_CYCLE, &cycle); DBAddOption(olist, DBOPT_DTIME, &time); DBAddOption(olist, DBOPT_NSPACE, &ndim ); if( field == rho_i || field == sx_i || field == sy_i || field == sz_i || field == spc_ac_i || field == spc_ae_i || field == spc_dc_i || field == spc_de_i || field == spc_vac_i ) { DBAddOption(olist, DBOPT_CONSERVED, &istrue); } else { DBAddOption(olist, DBOPT_CONSERVED, &isfalse ); } if( field < NF ) { DBAddOption(olist, DBOPT_EXTENSIVE, &istrue); } else { DBAddOption(olist, DBOPT_EXTENSIVE, &isfalse); } DBAddOption(olist, DBOPT_EXTENSIVE, &istrue); DBPutUcdvar1(db, field_names[field], "mesh", const_cast<void*>(reinterpret_cast<const void*>(olists.data[field].data())), nzones, nullptr, 0, DB_DOUBLE, DB_ZONECENT, olist); if( analytic && field < 6) { DBPutUcdvar1(db, analytic_names[field], "mesh", const_cast<void*>(reinterpret_cast<const void*>(olists.analytic[field].data())), nzones, nullptr, 0, DB_DOUBLE, DB_ZONECENT, olist); } DBFreeOptlist(olist); #ifdef RHO_ONLY break; #endif } DBClose(db); #endif }, _filename, _t).join(); #endif }
/*------------------------------------------------------------------------- * Function: test_ucdmesh * * Purpose: Test unstructured mesh functions. * * Return: Success: 0 * * Failure: number of errors * * Programmer: Robb Matzke * Thursday, April 1, 1999 * * Modifications: * *------------------------------------------------------------------------- */ static int test_ucdmesh(DBfile *dbfile) { int nerrors = 0; static double coordA[] = {101, 102, 103, 104, 105}; static double coordB[] = {201, 202, 203, 204, 205}; static double coordC[] = {301, 302, 303, 304, 305}; static double *coords[] = {coordA, coordB, coordC}; static char *coordnames[] = {"coordA", "coordB", "coordC"}; static int nnodes = NELMTS(coordA); static int ndims = NELMTS(coords); static int nzones = 3; static float varA[] = {1, 2, 3, 4, 5, 6, 7, 8}; static float *vars[] = {varA}; static char *varnames[] = {"varA"}; static int nels = NELMTS(varA); static int nvars = NELMTS(vars); static float mixA[] = {0.1, 0.2, 0.3}; static float *mixvars[] = {mixA}; static int mixlen = NELMTS(mixA); static int nodelist[] = {500, 501, 502, 503, 504, 505, 506, 507}; static int lnodelist = NELMTS(nodelist); static int shapecnt[] = {1, 1, 2, 2, 3, 3, 4, 4, 5, 5}; static int shapesize[]= {5, 5, 4, 4, 3, 3, 2, 2, 1, 1}; static int nshapes = NELMTS(shapecnt); static int typelist[] = {99, 98, 97, 96, 95, 94}; static int ntypes = NELMTS(typelist); static int types[] = {193, 192, 191, 190, 189, 187, 186}; static int zoneno[] = {185, 184, 183, 182, 181, 180, 179}; static int nfaces = NELMTS(types); static int origin = 1; puts("=== Ucdmesh ==="); DBMkDir(dbfile, "/ucd"); DBSetDir(dbfile, "/ucd"); /* Mesh */ if (DBPutUcdmesh(dbfile, "um1", ndims, coordnames, (float**)coords, nnodes, nzones, "zl1", "fl1", DB_DOUBLE, NULL)<0) { puts("DBPutUcdmesh(um1) failed"); nerrors++; } if (DBPutUcdsubmesh(dbfile, "um2", "um1", nzones, "zl1", "fl1", NULL)<0) { puts("DBPutUcdsubmesh(um2) failed"); nerrors++; } /* Variable */ if (DBPutUcdvar(dbfile, "uv1", "um1", nvars, varnames, vars, nels, mixvars, mixlen, DB_FLOAT, DB_NODECENT, NULL)<0) { puts("DBPutUcdvar(uv1) failed"); nerrors++; } /* Facelist */ if (DBPutFacelist(dbfile, "fl1", nfaces, ndims, nodelist, lnodelist, origin, zoneno, shapesize, shapecnt, nshapes, types, typelist, ntypes)<0) { puts("DBPutFacelist(fl1) failed"); nerrors++; } /* Zonelist */ if (DBPutZonelist(dbfile, "zl1", nzones, ndims, nodelist, lnodelist, origin, shapesize, shapecnt, nshapes)<0) { puts("DBPutZonelist(zl1) failed"); nerrors++; } return nerrors; }
int main(int argc, char **argv) { float x[1000],y[1000],z[1000]; float *coords[3]; int nodelist[2000]; int zoneno[1000]; int shapetype[1] = {DB_ZONETYPE_BEAM}; int shapesize[1] = {2}; int shapecnt[1]; /* fill this in later after we count the zones */ int nzones = 0; int nnodes = 0; int l; float zval[1000]; float nval[1000]; DBfile *db; int i,j, driver = DB_PDB, reorder = 0, friendly = 0; char *filename = "ucd1d.pdb"; int show_all_errors = FALSE; for (i=1; i<argc; i++) { if (!strncmp(argv[i], "DB_PDB", 6)) { driver = StringToDriver(argv[i]); filename = "ucd1d.pdb"; } else if (!strncmp(argv[i], "DB_HDF5", 7)) { driver = StringToDriver(argv[i]); filename = "ucd1d.h5"; } else if (!strcmp(argv[i], "reorder")) { reorder = 1; } else if (!strcmp(argv[i], "friendly")) { friendly = 1; } else if (!strcmp(argv[i], "show-all-errors")) { show_all_errors = 1; } else if (argv[i][0] != '\0') { fprintf(stderr, "%s: ignored argument `%s'\n", argv[0], argv[i]); } } if (show_all_errors) DBShowErrors(DB_ALL_AND_DRVR, 0); /* Create the coordinate arrays and the nodal variable */ for (i=0; i<30; i++) { for (j=0; j<=30; j++) { x[i*31+j] = (float)i-14.5; y[i*31+j] = sin(2*M_PI*(float)j/30)*5; z[i*31+j] = cos(2*M_PI*(float)j/30)*5; nval[nnodes] = sqrt(x[i*31+j]*x[i*31+j]*.2 + y[i*31+j]*y[i*31+j]*.5 + z[i*31+j]*z[i*31+j]*1.); nnodes++; } } if (reorder) { float tmp = nval[0]; nval[0] = nval[1]; nval[1] = tmp; } coords[0]=x; coords[1]=y; coords[2]=z; /* Create the connectivity arrays and teh zonal variable */ l=0; for (i=0; i<30; i++) { for (j=0; j<30; j++) { if (! (abs(i-j)<5 || abs(i-j+30)<5 || abs(i-j-30)<5)) { nodelist[l++] = (i*31 + j); nodelist[l++] = (i*31 + j+1); zoneno[nzones]=nzones; zval[nzones] = i+j; nzones++; } } } if (reorder) { float tmp = zval[nzones-1]; zval[nzones-1] = zval[nzones-2]; zval[nzones-2] = tmp; } shapecnt[0] = nzones; if (friendly && (driver&0xF) == DB_HDF5) DBSetFriendlyHDF5Names(1); /* Write out the mesh */ printf("Creating test file: \"%s\".\n", filename); db = DBCreate(filename, DB_CLOBBER, DB_LOCAL, "UCD mesh test", driver); DBPutUcdmesh(db,"mesh",3, NULL, coords, nnodes, nzones, NULL, "fl", DB_FLOAT, NULL); DBPutFacelist(db,"fl",nzones,3, nodelist,l, 0, zoneno, shapesize,shapecnt, 1, NULL,NULL,0); if (reorder) { DBPutUcdvar1(db, "nval", "mesh", nval, nnodes, NULL,0, DB_FLOAT, DB_NODECENT, NULL); DBPutUcdvar1(db, "zval", "mesh", zval, nzones, NULL,0, DB_FLOAT, DB_ZONECENT, NULL); } else { DBPutUcdvar1(db, "zval", "mesh", zval, nzones, NULL,0, DB_FLOAT, DB_ZONECENT, NULL); DBPutUcdvar1(db, "nval", "mesh", nval, nnodes, NULL,0, DB_FLOAT, DB_NODECENT, NULL); } DBClose(db); CleanupDriverStuff(); return(0); }
/*---------------------------------------------------------------------------- * Function: writemesh_ucd2d() * * Inputs: db (DBfile*): the Silo file handle * * Returns: (void) * * Abstract: Write the mesh and variables stored in the global Mesh * to the Silo file as a UCDmesh and UCDvars * * Modifications: *---------------------------------------------------------------------------*/ void writemesh_ucd2d(DBfile *db, int mixc, int reorder) { int nl[5000]; float f1[1000],f2[1000], fm[1000]; int x,y,c; char *coordnames[2]; float *coord[2]; int dims[2]; char *cnvar, *czvar; short *snvar, *szvar; int *invar, *izvar; long *lnvar, *lzvar; long long *Lnvar, *Lzvar; float *fnvar, *fzvar; double *dnvar, *dzvar; int lnodelist; int nnodes; int nzones; int shapesize[1]; int shapecnt[1]; /* do mesh */ c=0; for (x=0;x<mesh.nx;x++) { for (y=0;y<mesh.ny;y++) { f1[c]=mesh.node[x][y].x; f2[c]=mesh.node[x][y].y; if (mesh.node[x][y].c != c) { printf("Node mismatch! mesh.c=%d c=%d\n",mesh.node[x][y].c,c); exit(-1); } c++; } } coordnames[0]=NEW(char,20); coordnames[1]=NEW(char,20); strcpy(coordnames[0],"x"); strcpy(coordnames[1],"y"); coord[0]=f1; coord[1]=f2; dims[0]=mesh.nx; dims[1]=mesh.ny; /* create the zonelist */ c=0; for (x=0;x<mesh.zx;x++) { for (y=0;y<mesh.zy;y++) { nl[c++] = mesh.zone[x][y].n[0][0]->c; nl[c++] = mesh.zone[x][y].n[1][0]->c; nl[c++] = mesh.zone[x][y].n[1][1]->c; nl[c++] = mesh.zone[x][y].n[0][1]->c; } } lnodelist=c; nnodes=mesh.nx*mesh.ny; nzones=mesh.zx*mesh.zy; shapesize[0]=4; shapecnt[0]=nzones; DBSetDeprecateWarnings(0); DBPutZonelist(db,"Mesh_zonelist",nzones,2,nl,lnodelist,0,shapesize,shapecnt,1); DBSetDeprecateWarnings(3); DBPutUcdmesh (db,"Mesh",2,NULL,coord,nnodes,nzones,"Mesh_zonelist",NULL,DB_FLOAT,NULL); /* do Node vars */ cnvar = (char *) malloc(sizeof(char)*nnodes); snvar = (short *) malloc(sizeof(short)*nnodes); invar = (int *) malloc(sizeof(int)*nnodes); lnvar = (long *) malloc(sizeof(long)*nnodes); Lnvar = (long long *) malloc(sizeof(long long)*nnodes); fnvar = (float *) malloc(sizeof(float)*nnodes); dnvar = (double *) malloc(sizeof(double)*nnodes); c=0; for (x=0;x<mesh.nx;x++) { for (y=0;y<mesh.ny;y++) { f1[c]=mesh.node[x][y].vars[NV_U]; f2[c]=mesh.node[x][y].vars[NV_V]; cnvar[c] = (char) (x<y?x:y); snvar[c] = (short) (x<y?x:y); invar[c] = (int) (x<y?x:y); lnvar[c] = (long) (x<y?x:y); Lnvar[c] = (long long) (x<y?x:y); fnvar[c] = (float) (x<y?x:y); dnvar[c] = (double) (x<y?x:y); c++; } } { DBoptlist *opt = DBMakeOptlist(1); int val = DB_ON; DBAddOption(opt,DBOPT_USESPECMF,&val); DBPutUcdvar1(db, "u", "Mesh", f1, nnodes, NULL, 0, DB_FLOAT, DB_NODECENT, opt); DBPutUcdvar1(db, "v", "Mesh", f2, nnodes, NULL, 0, DB_FLOAT, DB_NODECENT, opt); DBPutUcdvar1(db, "u", "Mesh", f1, nnodes, NULL, 0, DB_FLOAT, DB_NODECENT, opt); DBPutUcdvar1(db, "v", "Mesh", f2, nnodes, NULL, 0, DB_FLOAT, DB_NODECENT, opt); DBPutUcdvar1(db, "cnvar", "Mesh", cnvar, nnodes, NULL, 0, DB_CHAR, DB_NODECENT, opt); DBPutUcdvar1(db, "snvar", "Mesh", snvar, nnodes, NULL, 0, DB_SHORT, DB_NODECENT, opt); DBPutUcdvar1(db, "invar", "Mesh", invar, nnodes, NULL, 0, DB_INT, DB_NODECENT, opt); DBPutUcdvar1(db, "lnvar", "Mesh", lnvar, nnodes, NULL, 0, DB_LONG, DB_NODECENT, opt); DBPutUcdvar1(db, "Lnvar", "Mesh", Lnvar, nnodes, NULL, 0, DB_LONG_LONG, DB_NODECENT, opt); DBPutUcdvar1(db, "fnvar", "Mesh", fnvar, nnodes, NULL, 0, DB_FLOAT, DB_NODECENT, opt); DBPutUcdvar1(db, "dnvar", "Mesh", dnvar, nnodes, NULL, 0, DB_DOUBLE, DB_NODECENT, opt); DBFreeOptlist(opt); } free(cnvar); free(snvar); free(invar); free(lnvar); free(Lnvar); free(fnvar); free(dnvar); /* do Zone vars */ dims[0]--; dims[1]--; czvar = (char *) malloc(sizeof(char)*nzones); szvar = (short *) malloc(sizeof(short)*nzones); izvar = (int *) malloc(sizeof(int)*nzones); lzvar = (long *) malloc(sizeof(long)*nzones); Lzvar = (long long *) malloc(sizeof(long long)*nzones); fzvar = (float *) malloc(sizeof(float)*nzones); dzvar = (double *) malloc(sizeof(double)*nzones); c=0; for (x=0;x<mesh.zx;x++) { for (y=0;y<mesh.zy;y++) { f1[c]=mesh.zone[x][y].vars[ZV_P]; f2[c]=mesh.zone[x][y].vars[ZV_D]; czvar[c] = (char) (x<y?x:y); szvar[c] = (short) (x<y?x:y); izvar[c] = (int) (x<y?x:y); lzvar[c] = (long) (x<y?x:y); Lzvar[c] = (long long) (x<y?x:y); fzvar[c] = (float) (x<y?x:y); dzvar[c] = (double) (x<y?x:y); c++; } } for (c=0; c<mixc; c++) fm[c] = 2.0/mixc*c; if (reorder) { float tmp=fm[mixc-1]; fm[mixc-1]=fm[mixc-2]; fm[mixc-2]=tmp; } DBPutUcdvar1(db, "p", "Mesh", f1, nzones, NULL, 0, DB_FLOAT, DB_ZONECENT, NULL); DBPutUcdvar1(db, "d", "Mesh", f2, nzones, fm, mixc, DB_FLOAT, DB_ZONECENT, NULL); DBPutUcdvar1(db, "czvar", "Mesh", czvar, nzones, NULL, 0, DB_CHAR, DB_ZONECENT, NULL); DBPutUcdvar1(db, "szvar", "Mesh", szvar, nzones, NULL, 0, DB_SHORT, DB_ZONECENT, NULL); DBPutUcdvar1(db, "izvar", "Mesh", izvar, nzones, NULL, 0, DB_INT, DB_ZONECENT, NULL); DBPutUcdvar1(db, "lzvar", "Mesh", lzvar, nzones, NULL, 0, DB_LONG, DB_ZONECENT, NULL); DBPutUcdvar1(db, "Lzvar", "Mesh", Lzvar, nzones, NULL, 0, DB_LONG_LONG, DB_ZONECENT, NULL); DBPutUcdvar1(db, "fzvar", "Mesh", fzvar, nzones, NULL, 0, DB_FLOAT, DB_ZONECENT, NULL); DBPutUcdvar1(db, "dzvar", "Mesh", dzvar, nzones, NULL, 0, DB_DOUBLE, DB_ZONECENT, NULL); free(czvar); free(szvar); free(izvar); free(lzvar); free(Lzvar); free(fzvar); free(dzvar); }
int main(int argc, char *argv[]) { DBfile *dbfile = NULL; char *coordnames[3]; float *coords[3]; float x[64], y[64], z[64]; int shapesize[1]; int shapecnt[1]; DBfacelist *facelist = NULL; int matnos[1], matlist[1], dims[3]; int i, j, k, len; float evar2d[2*16], evar3d[3*64], fvar3d[3*64]; int driver = DB_PDB; char *filename = "efcentering.silo"; int layer, zone; int nodelist2[9*4] = {0,1,5,4, 1,2,6,5, 2,3,7,6, 4,5,9,8, 5,6,10,9, 6,7,11,10, 8,9,13,12, 9,10,14,13, 10,11,15,14}; int st2 = DB_ZONETYPE_QUAD; int ss2 = 4; int sc2 = 9; int nodelist3[27*8]; int st3 = DB_ZONETYPE_HEX; int ss3 = 8; int sc3 = 27; int nedges; int *edges; int nfaces; int *faces; int ndims; int show_all_errors = FALSE; /* Parse command-line */ for (i=1; i<argc; i++) { if (!strncmp(argv[i], "DB_PDB",6)) { driver = StringToDriver(argv[i]); } else if (!strncmp(argv[i], "DB_HDF5", 7)) { driver = StringToDriver(argv[i]); } else if (!strcmp(argv[i], "show-all-errors")) { show_all_errors = 1; } else if (argv[i][0] != '\0') { fprintf(stderr, "%s: ignored argument `%s'\n", argv[0], argv[i]); } } DBShowErrors(show_all_errors?DB_ALL_AND_DRVR:DB_ABORT, NULL); dbfile = DBCreate(filename, DB_CLOBBER, DB_LOCAL, "edge and face centered data", driver); coordnames[0] = "xcoords"; coordnames[1] = "ycoords"; coordnames[2] = "zcoords"; dims[0] = 4; dims[1] = 4; dims[2] = 4; for (k = 0; k < 4; k++) { for (j = 0; j < 4; j++) { for (i = 0; i < 4; i++) { x[k*4*4+j*4+i] = (float) i; y[k*4*4+j*4+i] = (float) j; z[k*4*4+j*4+i] = (float) k; evar2d[0*16+j*4+i] = (float) i; evar2d[1*16+j*4+i] = (float) j; evar3d[0*64+k*4*4+j*4+i] = (float) i; evar3d[1*64+k*4*4+j*4+i] = (float) j; evar3d[2*64+k*4*4+j*4+i] = (float) k; fvar3d[0*64+k*4*4+j*4+i] = (float) 10*i; fvar3d[1*64+k*4*4+j*4+i] = (float) 100*j; fvar3d[2*64+k*4*4+j*4+i] = (float) 1000*k; } } } coords[0] = x; coords[1] = y; coords[2] = z; /* build 3d zonelist by layering 2d zonelist */ for (layer = 0; layer < 3; layer++) { for (zone = 0; zone < 9; zone++) { nodelist3[layer*9*8+zone*8+0] = nodelist2[zone*4+0]+(layer+1)*16; nodelist3[layer*9*8+zone*8+1] = nodelist2[zone*4+0]+layer*16; nodelist3[layer*9*8+zone*8+2] = nodelist2[zone*4+1]+layer*16; nodelist3[layer*9*8+zone*8+3] = nodelist2[zone*4+1]+(layer+1)*16; nodelist3[layer*9*8+zone*8+4] = nodelist2[zone*4+3]+(layer+1)*16; nodelist3[layer*9*8+zone*8+5] = nodelist2[zone*4+3]+layer*16; nodelist3[layer*9*8+zone*8+6] = nodelist2[zone*4+2]+layer*16; nodelist3[layer*9*8+zone*8+7] = nodelist2[zone*4+2]+(layer+1)*16; } } DBPutQuadmesh(dbfile, "qmesh2", (DBCAS_t) coordnames, coords, dims, 2, DB_FLOAT, DB_NONCOLLINEAR, 0); DBPutQuadmesh(dbfile, "qmesh3", (DBCAS_t) coordnames, coords, dims, 3, DB_FLOAT, DB_NONCOLLINEAR, 0); DBPutQuadvar1(dbfile, "qevar2", "qmesh2", evar2d, dims, 2, 0, 0, DB_FLOAT, DB_EDGECENT, 0); DBPutQuadvar1(dbfile, "qevar3", "qmesh3", evar3d, dims, 3, 0, 0, DB_FLOAT, DB_EDGECENT, 0); DBPutQuadvar1(dbfile, "qfvar3", "qmesh3", fvar3d, dims, 3, 0, 0, DB_FLOAT, DB_FACECENT, 0); DBPutUcdmesh(dbfile, "umesh2", 2, (DBCAS_t) coordnames, coords, 16, 9, "um2zl", 0, DB_FLOAT, 0); DBPutUcdmesh(dbfile, "umesh3", 3, (DBCAS_t) coordnames, coords, 64, 27, "um3zl", 0, DB_FLOAT, 0); DBPutZonelist2(dbfile, "um2zl", 9, 2, nodelist2, ss2*sc2, 0, 0, 0, &st2, &ss2, &sc2, 1, 0); DBPutZonelist2(dbfile, "um3zl", 27, 3, nodelist3, ss3*sc3, 0, 0, 0, &st3, &ss3, &sc3, 1, 0); /* Only reason we build an edgelist is so we know the number of unique edges in the mesh */ build_edgelist(27, 3, nodelist3, ss3*sc3, 0, 0, 0, &st3, &ss3, &sc3, 1, &nedges, &edges); for (i = 0; i < nedges; i++) evar3d[i] = i; DBPutUcdvar1(dbfile, "uevar3", "umesh3", evar3d, nedges, 0, 0, DB_FLOAT, DB_EDGECENT, 0); ndims = 2; dims[0] = nedges; dims[1] = 2; DBWrite(dbfile, "edges", edges, dims, ndims, DB_INT); free(edges); /* Only reason we build a facelist is so we know the number of unique faces in the mesh */ build_facelist(27, 3, nodelist3, ss3*sc3, 0, 0, 0, &st3, &ss3, &sc3, 1, &nfaces, &faces); for (i = 0; i < nfaces; i++) fvar3d[i] = i; DBPutUcdvar1(dbfile, "ufvar3", "umesh3", fvar3d, nfaces, 0, 0, DB_FLOAT, DB_FACECENT, 0); dims[0] = nfaces; dims[1] = 4; DBWrite(dbfile, "faces", faces, dims, ndims, DB_INT); free(faces); DBClose(dbfile); CleanupDriverStuff(); return (0); }
int main(int argc, char *argv[]) { int driver = DB_PDB; char *filename = "empty.silo"; int show_all_errors = FALSE; int i, pass; char const * const cnames[3] = {"x","y","z"}; void *coords[3] = {(void*)1,(void*)2,(void*)3}; /* really funky dummy pointers */ void *vars[3] = {(void*)1,(void*)2,(void*)3}; /* really funky dummy pointers */ void const * const vvars[3] = {(void*)1,(void*)2,(void*)3}; /* really funky dummy pointers */ void *var = (void*)1; int iarr[3] = {1,1,1}; /* dummy int array */ int ZDIMS[3] = {0,0,0}; double exts[4] = {0,0,0,0}; DBoptlist *ol = 0; double dtime = 0.0; int hide_from_gui=0; int *gnodeno = 0; int *gzoneno = 0; char *ghostn = 0; char *ghostz = 0; /* Parse command-line */ for (i=1; i<argc; i++) { if (!strncmp(argv[i], "DB_", 3)) { driver = StringToDriver(argv[i]); } else if (!strcmp(argv[i], "show-all-errors")) { show_all_errors = 1; } else if (argv[i][0] != '\0') { fprintf(stderr, "%s: ignored argument `%s'\n", argv[0], argv[i]); } } DBSetDeprecateWarnings(0); DBShowErrors(show_all_errors?DB_ALL_AND_DRVR:DB_NONE, NULL); printf("Creating test file \"%s\".\n", filename); dbfile = DBCreate(filename, DB_CLOBBER, DB_LOCAL, "test empty silo objects", driver); ol = DBMakeOptlist(10); DBAddOption(ol, DBOPT_DTIME, &dtime); DBAddOption(ol, DBOPT_HIDE_FROM_GUI, &hide_from_gui); DBAddOption(ol, DBOPT_NODENUM, gnodeno); DBAddOption(ol, DBOPT_ZONENUM, gzoneno); DBAddOption(ol, DBOPT_GHOST_NODE_LABELS, ghostn); DBAddOption(ol, DBOPT_GHOST_ZONE_LABELS, ghostz); /* first pass confirms we catch bad arguments; second pass confirms we permit empty objects */ for (pass = 0; pass < 2; pass++) { const int dt = DB_FLOAT; const int ct = DB_ZONECENT; const int ZZ = 0; /* Used for sole arg causing emptiness */ if (pass) DBSetAllowEmptyObjects(1); /* Because references to the following objects will not ever appear in a multi-xxx object, we do not currently test for support of empties... DBPutUcdsubmesh, DBPutMrgtree, DBPutMrgvar, DBPutGroupelmap Note: 'ZZ' or 'ZDIMS' is the key argument in each call that triggers an empty */ /* empty curve objects */ ASSERT(DBPutCurve(dbfile,"empty_curvea",coords[0],coords[0],dt,ZZ,OL(ol)),retval<0,retval==0); ASSERT(DBPutCurve(dbfile,"empty_curveb", 0,coords[0],dt,ZZ,OL(ol)),retval<0,retval==0); ASSERT(DBPutCurve(dbfile,"empty_curvec",coords[0], 0,dt,ZZ,OL(ol)),retval<0,retval==0); /* empty point meshes and vars */ ASSERT(DBPutPointmesh(dbfile,"empty_pointmesha",1,coords,ZZ,dt,OL(ol)),retval<0,retval==0); ASSERT(DBPutPointmesh(dbfile,"empty_pointmeshb",3, 0,ZZ,dt,OL(ol)),retval<0,retval==0); ASSERT(DBPutPointvar(dbfile,"pva","empty_pointmesha",1,vars,ZZ,dt,OL(ol)),retval<0,retval==0); ASSERT(DBPutPointvar(dbfile,"pvb","empty_pointmesha",3, 0,ZZ,dt,OL(ol)),retval<0,retval==0); ASSERT(DBPutPointvar1(dbfile,"pv1a","empty_pointmesha",var,ZZ,dt,OL(ol)),retval<0,retval==0); ASSERT(DBPutPointvar1(dbfile,"pv1b","empty_pointmesha", 0,ZZ,dt,OL(ol)),retval<0,retval==0); /* empty quad meshes and vars (ZDIMS is the magic zero'ing arg) */ ASSERT(DBPutQuadmesh(dbfile,"empty_quadmesha", 0,coords,ZDIMS,1,dt,DB_COLLINEAR,OL(ol)),retval<0,retval==0); ASSERT(DBPutQuadmesh(dbfile,"empty_quadmeshb",cnames, 0,ZDIMS,2,dt,DB_COLLINEAR,OL(ol)),retval<0,retval==0); ASSERT(DBPutQuadmesh(dbfile,"empty_quadmeshc",cnames,coords,ZDIMS,3,dt,DB_COLLINEAR,OL(ol)),retval<0,retval==0); ASSERT(DBPutQuadvar(dbfile,"qva","empty_quadmesha",2, 0,vars,ZDIMS,2,0,0,dt,ct,OL(ol)),retval<0,retval==0); ASSERT(DBPutQuadvar(dbfile,"qvb","empty_quadmesha",3,cnames, 0,ZDIMS,3,0,0,dt,ct,OL(ol)),retval<0,retval==0); ASSERT(DBPutQuadvar1(dbfile,"qv1a","empty_quadmesha", 0,ZDIMS,ZZ,var,0,dt,ct,OL(ol)),retval<0,retval==0); ASSERT(DBPutQuadvar1(dbfile,"qv1b","empty_quadmesha",var,ZDIMS,ZZ, 0,0,dt,ct,OL(ol)),retval<0,retval==0); /* empty ucd meshes, facelists, zonelists and vars */ ASSERT(DBPutUcdmesh(dbfile,"empty_ucdmesh1",3,cnames,coords,ZZ,1,"foo","bar",dt,OL(ol)),retval<0,retval==0); ASSERT(DBPutUcdmesh(dbfile,"empty_ucdmesh2",1, 0,coords,ZZ,1,"foo","bar",dt,OL(ol)),retval<0,retval==0); ASSERT(DBPutUcdmesh(dbfile,"empty_ucdmesh3",2,cnames, 0,ZZ,0,"foo","bar",dt,OL(ol)),retval<0,retval==0); ASSERT(DBPutUcdmesh(dbfile,"empty_ucdmesh3",0, 0, 0,ZZ,0, 0, 0,dt,OL(ol)),retval<0,retval==0); ASSERT(DBPutFacelist(dbfile,"empty_facelista",ZZ,0,iarr,1,1,iarr,iarr,iarr,1,iarr,iarr,1),retval<0,retval==0); ASSERT(DBPutFacelist(dbfile,"empty_facelistb",ZZ,0, 0,1,1,iarr,iarr,iarr,1,iarr,iarr,1),retval<0,retval==0); ASSERT(DBPutFacelist(dbfile,"empty_facelistc",ZZ,0,iarr,1,1, 0,iarr,iarr,1,iarr,iarr,1),retval<0,retval==0); ASSERT(DBPutFacelist(dbfile,"empty_facelistd",ZZ,0,iarr,1,1,iarr, 0,iarr,1,iarr,iarr,1),retval<0,retval==0); ASSERT(DBPutFacelist(dbfile,"empty_faceliste",ZZ,0,iarr,1,1,iarr,iarr, 0,1,iarr,iarr,1),retval<0,retval==0); ASSERT(DBPutFacelist(dbfile,"empty_facelistf",ZZ,0,iarr,1,1,iarr,iarr,iarr,1, 0,iarr,1),retval<0,retval==0); ASSERT(DBPutFacelist(dbfile,"empty_facelistg",ZZ,0,iarr,1,1,iarr,iarr,iarr,1,iarr, 0,1),retval<0,retval==0); ASSERT(DBPutZonelist(dbfile,"empty_zonelista",ZZ,1,iarr,10,0,iarr,iarr,10),retval<0,retval==0); ASSERT(DBPutZonelist(dbfile,"empty_zonelistb",ZZ,1, 0,10,0,iarr,iarr,10),retval<0,retval==0); ASSERT(DBPutZonelist(dbfile,"empty_zonelistc",ZZ,1,iarr,10,0, 0,iarr,10),retval<0,retval==0); ASSERT(DBPutZonelist(dbfile,"empty_zonelistd",ZZ,1,iarr,10,0,iarr, 0,10),retval<0,retval==0); ASSERT(DBPutZonelist2(dbfile,"empty_zonelist2a",ZZ,1,iarr,1,0,0,0,iarr,iarr,iarr,1,OL(ol)),retval<0,retval==0); ASSERT(DBPutZonelist2(dbfile,"empty_zonelist2b",ZZ,0, 0,1,3,3,3,iarr,iarr,iarr,1,OL(ol)),retval<0,retval==0); ASSERT(DBPutZonelist2(dbfile,"empty_zonelist2c",ZZ,1,iarr,0,3,3,3, 0,iarr,iarr,1,OL(ol)),retval<0,retval==0); ASSERT(DBPutZonelist2(dbfile,"empty_zonelist2d",ZZ,1,iarr,1,0,3,0,iarr, 0,iarr,0,OL(ol)),retval<0,retval==0); ASSERT(DBPutZonelist2(dbfile,"empty_zonelist2e",ZZ,1,iarr,1,3,0,0,iarr,iarr, 0,1,OL(ol)),retval<0,retval==0); ASSERT(DBPutPHZonelist(dbfile,"empty_phzonelista",ZZ,iarr,1,iarr,cnames[0],1,iarr,1,iarr,0,0,0,OL(ol)),retval<0,retval==0); ASSERT(DBPutPHZonelist(dbfile,"empty_phzonelistb",ZZ, 0,1,iarr,cnames[0],1,iarr,1,iarr,0,0,0,OL(ol)),retval<0,retval==0); ASSERT(DBPutPHZonelist(dbfile,"empty_phzonelistc",ZZ,iarr,1, 0,cnames[0],1,iarr,1,iarr,0,0,0,OL(ol)),retval<0,retval==0); ASSERT(DBPutPHZonelist(dbfile,"empty_phzonelistd",ZZ,iarr,1,iarr, 0,1,iarr,1,iarr,0,0,0,OL(ol)),retval<0,retval==0); ASSERT(DBPutPHZonelist(dbfile,"empty_phzoneliste",ZZ,iarr,1,iarr,cnames[0],1, 0,1,iarr,0,0,0,OL(ol)),retval<0,retval==0); ASSERT(DBPutPHZonelist(dbfile,"empty_phzonelistf",ZZ,iarr,1,iarr,cnames[0],1,iarr,1, 0,0,0,0,OL(ol)),retval<0,retval==0); ASSERT(DBPutUcdvar(dbfile,"uva","empty_ucdmesh1",0,cnames,vars,ZZ,vars,1,dt,ct,OL(ol)),retval<0,retval==0); ASSERT(DBPutUcdvar(dbfile,"uvb","empty_ucdmesh1",1, 0,vars,ZZ,vars,1,dt,ct,OL(ol)),retval<0,retval==0); ASSERT(DBPutUcdvar(dbfile,"uvc","empty_ucdmesh1",2,cnames, 0,ZZ,vars,1,dt,ct,OL(ol)),retval<0,retval==0); ASSERT(DBPutUcdvar(dbfile,"uvd","empty_ucdmesh1",3,cnames,vars,ZZ, 0,1,dt,ct,OL(ol)),retval<0,retval==0); ASSERT(DBPutUcdvar(dbfile,"uve","empty_ucdmesh1",3, 0, 0,ZZ, 0,1,dt,ct,OL(ol)),retval<0,retval==0); ASSERT(DBPutUcdvar1(dbfile,"uv1a","empty_ucdmesh1",var,ZZ,vars[0],1,dt,ct,OL(ol)),retval<0,retval==0); ASSERT(DBPutUcdvar1(dbfile,"uv1b","empty_ucdmesh1", 0,ZZ,vars[0],1,dt,ct,OL(ol)),retval<0,retval==0); ASSERT(DBPutUcdvar1(dbfile,"uv1c","empty_ucdmesh1",var,ZZ, 0,1,dt,ct,OL(ol)),retval<0,retval==0); ASSERT(DBPutUcdvar1(dbfile,"uv1d","empty_ucdmesh1", 0,ZZ, 0,1,dt,ct,OL(ol)),retval<0,retval==0); /* csg meshes and vars */ ASSERT(DBPutCsgmesh(dbfile,"empty_csgmesh1",2,ZZ, 0,iarr,var,1,dt,exts,"foo",OL(ol)),retval<0,retval==0); ASSERT(DBPutCsgmesh(dbfile,"empty_csgmesh2",2,ZZ,iarr, 0,var,2,dt,exts,"foo",OL(ol)),retval<0,retval==0); ASSERT(DBPutCsgmesh(dbfile,"empty_csgmesh3",3,ZZ,iarr,iarr, 0,3,dt,exts,"foo",OL(ol)),retval<0,retval==0); ASSERT(DBPutCsgmesh(dbfile,"empty_csgmesh4",3,ZZ,iarr,iarr,var,0,dt,exts,"foo",OL(ol)),retval<0,retval==0); ASSERT(DBPutCSGZonelist(dbfile,"empty_csgzonelista",0,iarr,iarr,iarr,0,0,dt,ZZ,iarr,OL(ol)),retval<0,retval==0); ASSERT(DBPutCSGZonelist(dbfile,"empty_csgzonelistb",1, 0,iarr,iarr,0,0,dt,ZZ,iarr,OL(ol)),retval<0,retval==0); ASSERT(DBPutCSGZonelist(dbfile,"empty_csgzonelistc",1,iarr, 0,iarr,0,0,dt,ZZ,iarr,OL(ol)),retval<0,retval==0); ASSERT(DBPutCSGZonelist(dbfile,"empty_csgzonelistd",1,iarr,iarr, 0,0,0,dt,ZZ,iarr,OL(ol)),retval<0,retval==0); ASSERT(DBPutCSGZonelist(dbfile,"empty_csgzoneliste",1,iarr,iarr,iarr,0,0,dt,ZZ, 0,OL(ol)),retval<0,retval==0); ASSERT(DBPutCsgvar(dbfile,"csgva","empty_csgmesh1",0,cnames,vvars,ZZ,dt,ct,OL(ol)),retval<0,retval==0); ASSERT(DBPutCsgvar(dbfile,"csgvb","empty_csgmesh1",1, 0,vvars,ZZ,dt,ct,OL(ol)),retval<0,retval==0); ASSERT(DBPutCsgvar(dbfile,"csgvc","empty_csgmesh1",1,cnames, 0, ZZ,dt,ct,OL(ol)),retval<0,retval==0); ASSERT(DBPutCsgvar(dbfile,"csgvd","empty_csgmesh1",1,cnames,vvars,ZZ,dt,ct,OL(ol)),retval<0,retval==0); /* empty materials and species */ ASSERT(DBPutMaterial(dbfile,"empty_mata","foo",1,iarr,iarr,ZDIMS,1,iarr,iarr,iarr,vars[0],1,dt,OL(ol)),retval<0,retval==0); ASSERT(DBPutMaterial(dbfile,"empty_matb","foo",1, 0,iarr,ZDIMS,1,iarr,iarr,iarr,vars[0],1,dt,OL(ol)),retval<0,retval==0); ASSERT(DBPutMaterial(dbfile,"empty_matc","foo",1,iarr, 0,ZDIMS,1,iarr,iarr,iarr,vars[0],1,dt,OL(ol)),retval<0,retval==0); ASSERT(DBPutMaterial(dbfile,"empty_matd","foo",1,iarr,iarr,ZDIMS,1, 0,iarr,iarr,vars[0],1,dt,OL(ol)),retval<0,retval==0); ASSERT(DBPutMaterial(dbfile,"empty_mate","foo",1,iarr,iarr,ZDIMS,1,iarr, 0,iarr,vars[0],1,dt,OL(ol)),retval<0,retval==0); ASSERT(DBPutMaterial(dbfile,"empty_matf","foo",1,iarr,iarr,ZDIMS,1,iarr,iarr, 0,vars[0],1,dt,OL(ol)),retval<0,retval==0); ASSERT(DBPutMaterial(dbfile,"empty_matg","foo",1,iarr,iarr,ZDIMS,1,iarr,iarr,iarr, 0,1,dt,OL(ol)),retval<0,retval==0); /* empty matspecies via dims[i] == 0 */ ASSERT(DBPutMatspecies(dbfile,"empty_speca","empty_mata",1,iarr,iarr,ZDIMS,1,1,var,iarr,1,dt,OL(ol)),retval<0,retval==0); ASSERT(DBPutMatspecies(dbfile,"empty_specb","empty_mata",1,iarr,iarr,ZDIMS,2,1,var,iarr,1,dt,OL(ol)),retval<0,retval==0); ASSERT(DBPutMatspecies(dbfile,"empty_specc","empty_mata",1,iarr,iarr,ZDIMS,3,1,var,iarr,1,dt,OL(ol)),retval<0,retval==0); ASSERT(DBPutMatspecies(dbfile,"empty_specd","empty_mata",1,iarr,iarr,ZDIMS,1,1, 0,iarr,1,dt,OL(ol)),retval<0,retval==0); ASSERT(DBPutMatspecies(dbfile,"empty_spece","empty_mata",1,iarr,iarr,ZDIMS,1,1,var, 0,0,dt,OL(ol)),retval<0,retval==0); /* empty matspeces via nspecies_mf==0 */ { int nd=2, d[2]={3,2}, slm[6]={0,0,-1,-3,0,0}, ml=4, msl[4]={1,2,1,2}, slc[6]={0,0,0,0,0,0}; ASSERT(DBPutMatspecies(dbfile,"empty_specf","empty_mata",1,iarr,slc,d,nd,ZZ,var, 0, 0,dt,OL(ol)),retval<0,retval==0); ASSERT(DBPutMatspecies(dbfile,"empty_specg","empty_mata",1,iarr,slm,d,nd,ZZ,var,msl,ml,dt,OL(ol)),retval<0,retval==0); } } DBClose(dbfile); dbfile = 0; /* Ok, now try to read each empty object to make sure we get what we expect and nothing fails */ dbfile = DBOpen(filename, DB_UNKNOWN, DB_READ); /* test read back of empty curves */ { int i=0; char *cnames[] = {"empty_curvea", "empty_curveb", "empty_curvec", 0}; DBSetDir(dbfile, "DBPutCurve"); while (cnames[i]) { DBcurve *curve = DBGetCurve(dbfile, cnames[i++]); assert(DBIsEmptyCurve(curve)); DBFreeCurve(curve); } DBSetDir(dbfile, ".."); } /* test read back of empty point meshes and vars */ { int i=0; char *pmnames[] = {"empty_pointmesha", "empty_pointmeshb", 0}; DBSetDir(dbfile, "DBPutPointmesh"); while (pmnames[i]) { DBpointmesh *pointmesh = DBGetPointmesh(dbfile, pmnames[i++]); assert(DBIsEmptyPointmesh(pointmesh)); DBFreePointmesh(pointmesh); } DBSetDir(dbfile, ".."); } { int i=0; char *vnames[] = {"pva", "pvb", "pv1a", "pv1b", 0}; DBSetDir(dbfile, "DBPutPointvar"); while (vnames[i]) { DBpointvar *pointvar = DBGetPointvar(dbfile, vnames[i++]); assert(DBIsEmptyPointvar(pointvar)); DBFreePointvar(pointvar); } DBSetDir(dbfile, ".."); } /* test read back of empty quad meshes and vars */ { int i=0; char *qmnames[] = {"empty_quadmesha", "empty_quadmeshb", "empty_quadmeshc", 0}; DBSetDir(dbfile, "DBPutQuadmesh"); while (qmnames[i]) { DBquadmesh *quadmesh = DBGetQuadmesh(dbfile, qmnames[i++]); assert(DBIsEmptyQuadmesh(quadmesh)); DBFreeQuadmesh(quadmesh); } DBSetDir(dbfile, ".."); } { int i=0; char *vnames[] = {"qva" , "qvb", "qv1a", "qv1b", 0}; DBSetDir(dbfile, "DBPutQuadvar"); while (vnames[i]) { DBquadvar *quadvar = DBGetQuadvar(dbfile, vnames[i++]); assert(DBIsEmptyQuadvar(quadvar)); DBFreeQuadvar(quadvar); } DBSetDir(dbfile, ".."); } /* test read back of empty ucd meshes, zonelists and vars */ { int i=0; char *mnames[] = {"empty_ucdmesh1", "empty_ucdmesh2", "empty_ucdmesh3", 0}; DBSetDir(dbfile, "DBPutUcdmesh"); while (mnames[i]) { DBucdmesh *ucdmesh = DBGetUcdmesh(dbfile, mnames[i++]); assert(DBIsEmptyUcdmesh(ucdmesh)); DBFreeUcdmesh(ucdmesh); } DBSetDir(dbfile, ".."); } { int i=0; char *flnames[] = {"empty_facelista", "empty_facelistb", "empty_facelistc", "empty_facelistd", "empty_faceliste", "empty_facelistf", "empty_facelistg", 0}; DBSetDir(dbfile, "DBPutFacelist"); while (flnames[i]) { DBfacelist *fl = DBGetFacelist(dbfile, flnames[i++]); assert(DBIsEmptyFacelist(fl)); DBFreeFacelist(fl); } DBSetDir(dbfile, ".."); } { int i=0; char *zlnames[] = {"empty_zonelista", "empty_zonelistb", "empty_zonelistc", "empty_zonelistd", "empty_zonelist2a", "empty_zonelist2b", "empty_zonelist2c", "empty_zonelist2d", "empty_zonelist2e", 0}; DBSetDir(dbfile, "DBPutZonelist"); while (zlnames[i]) { DBzonelist *zl = DBGetZonelist(dbfile, zlnames[i++]); assert(DBIsEmptyZonelist(zl)); DBFreeZonelist(zl); } DBSetDir(dbfile, ".."); } { int i=0; char *zlnames[] = {"empty_phzonelista", "empty_phzonelistb", "empty_phzonelistc", "empty_phzonelistd", "empty_phzoneliste", "empty_phzonelistf", 0}; DBSetDir(dbfile, "DBPutPHZonelist"); while (zlnames[i]) { DBphzonelist *zl = DBGetPHZonelist(dbfile, zlnames[i++]); assert(DBIsEmptyPHZonelist(zl)); DBFreePHZonelist(zl); } DBSetDir(dbfile, ".."); } { int i=0; char *vnames[] = { "uva", "uvb", "uvc", "uvd", "uve", "uv1a", "uv1b", "uv1c", "uv1d", 0}; DBSetDir(dbfile, "DBPutUcdvar"); while (vnames[i]) { DBucdvar *ucdvar = DBGetUcdvar(dbfile, vnames[i++]); assert(DBIsEmptyUcdvar(ucdvar)); DBFreeUcdvar(ucdvar); } DBSetDir(dbfile, ".."); } /* test read back of empty csg meshes and vars */ { int i=0; char *mnames[] = {"empty_csgmesh1", "empty_csgmesh2", "empty_csgmesh3", 0}; DBSetDir(dbfile, "DBPutCsgmesh"); while (mnames[i]) { DBcsgmesh *csgmesh = DBGetCsgmesh(dbfile, mnames[i++]); assert(DBIsEmptyCsgmesh(csgmesh)); DBFreeCsgmesh(csgmesh); } DBSetDir(dbfile, ".."); } { int i=0; char *zlnames[] = {"empty_csgzonelista", "empty_csgzonelistb", "empty_csgzonelistc", "empty_csgzonelistd", "empty_csgzoneliste", 0}; DBSetDir(dbfile, "DBPutCSGZonelist"); while (zlnames[i]) { DBcsgzonelist *zl = DBGetCSGZonelist(dbfile, zlnames[i++]); assert(DBIsEmptyCSGZonelist(zl)); DBFreeCSGZonelist(zl); } DBSetDir(dbfile, ".."); } { int i=0; char *vnames[] = {"csgva", "csgvb", "csgvc", "csgvd", 0}; DBSetDir(dbfile, "DBPutCsgvar"); while (vnames[i]) { DBcsgvar *csgvar = DBGetCsgvar(dbfile, vnames[i++]); assert(DBIsEmptyCsgvar(csgvar)); DBFreeCsgvar(csgvar); } DBSetDir(dbfile, ".."); } /* test read back of empty materials and matspecies */ { int i=0; char *vnames[] = {"empty_mata", "empty_matb", "empty_matc", "empty_matd", "empty_mate", "empty_matf", "empty_matg", 0}; DBSetDir(dbfile, "DBPutMaterial"); while (vnames[i]) { DBmaterial *mat = DBGetMaterial(dbfile, vnames[i++]); assert(DBIsEmptyMaterial(mat)); DBFreeMaterial(mat); } DBSetDir(dbfile, ".."); } { int i=0; char *vnames[] = {"empty_speca", "empty_specb", "empty_specc", "empty_specd", "empty_spece", "empty_specf", "empty_specg", 0}; DBSetDir(dbfile, "DBPutMatspecies"); while (vnames[i]) { DBmatspecies *spec = DBGetMatspecies(dbfile, vnames[i++]); assert(DBIsEmptyMatspecies(spec)); DBFreeMatspecies(spec); } DBSetDir(dbfile, ".."); } DBClose(dbfile); CleanupDriverStuff(); return 0; }
int main(int argc, char **argv) { DBfile *dbfile; int N = 21; int driver = DB_PDB; int i = 1; while (i < argc) { if (strcmp(argv[i], "-driver") == 0) { i++; if (strcmp(argv[i], "DB_HDF5") == 0) { driver = DB_HDF5; } else if (strcmp(argv[i], "DB_PDB") == 0) { driver = DB_PDB; } else { fprintf(stderr,"Uncrecognized driver name \"%s\"\n", argv[i]); exit(-1); } } else if (strcmp(argv[i], "-n") == 0) { i++; N = atoi(argv[i]); if (N < 0 || N > 10000) { fprintf(stderr,"size, %d, too large\n", N); exit(-1); } if (N % 2 != 1) { fprintf(stderr,"size, %d, should be an odd number\n", N); exit(-1); } } i++; } float x[] = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; float y[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}; float *coords[2] = {x, y}; dbfile = DBCreate("lineout_test.silo", DB_CLOBBER, DB_LOCAL, "2D grid with stair-step and linear fields", driver); char *coordnames[2]; coordnames[0] = "xcoords"; coordnames[1] = "ycoords"; int zonelist[] = {0,1,7,6, 1,2,8,7, 2,3,9,8, 3,4,10,9, 4,5,11,10}; int zshapetype = DB_ZONETYPE_QUAD; int zshapesize = 4; int zshapecnt = 5; DBPutZonelist2(dbfile, "zl2d", 5, 2, zonelist, sizeof(zonelist)/sizeof(zonelist[0]), 0, 0, 0, &zshapetype, &zshapesize, &zshapecnt, 1, NULL); DBPutUcdmesh(dbfile, "mesh", 2, coordnames, coords, 12, 5, "zl2d", NULL, DB_FLOAT, NULL); float zc_var[] = {0.5, 1.5, 2.5, 3.5, 4.5}; DBPutUcdvar1(dbfile, "zonal_var", "mesh", zc_var, 5, NULL, 0, DB_FLOAT, DB_ZONECENT, NULL); float nc_var[] = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; DBPutUcdvar1(dbfile, "nodal_var", "mesh", nc_var, 12, NULL, 0, DB_FLOAT, DB_NODECENT, NULL); float x1[] = {-1.5, -.5, 0.5, 1.5, -1.5, -.5, 0.5, 1.5, -1.5, -.5, 0.5, 1.5, -1.5, -.5, 0.5, 1.5}; float y1[] = {-1.5, -1.5, -1.5, -1.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 1.5, 1.5, 1.5, 1.5}; int zonelist2[] = {0,1,5,4, 1,2,6,5, 2,3,7,6, 4,5,9,8, 5,6,10,9, 6,7,11,10, 8,9,13,12, 9,10,14,13,10,11,15,14}; zshapecnt = 9; DBPutZonelist2(dbfile, "zl2d2", 9, 2, zonelist2, sizeof(zonelist2)/sizeof(zonelist2[0]), 0, 0, 0, &zshapetype, &zshapesize, &zshapecnt, 1, NULL); coords[0] = x1; coords[1] = y1; DBPutUcdmesh(dbfile, "mesh2", 2, coordnames, coords, 16, 9, "zl2d2", NULL, DB_FLOAT, NULL); float zc_var2[] = {1.5, 0, -1.5, 0, 0, 0, -1.5, 0, 1.5}; DBPutUcdvar1(dbfile, "zonal_var2", "mesh2", zc_var2, 9, NULL, 0, DB_FLOAT, DB_ZONECENT, NULL); // This is designed to yield a perfect quadratic along the diagonal // y=x and y=-x lineouts such that value of nc_var2 is equal to distance // from origin (0,0), squared. A resulting lineout *should* look like a // perfect quadratic curve. float a = (1.5*1.5 + 1.5*1.5); float b = (0.5*0.5 + 1.5*1.5); float c = (0.5*0.5 + 0.5*0.5); float nc_var2[] = {-a, -b, b, a, -b, -c, c, b, b, c, -c, -b, a, b, -b, -a}; DBPutUcdvar1(dbfile, "nodal_var2", "mesh2", nc_var2, 16, NULL, 0, DB_FLOAT, DB_NODECENT, NULL); DBClose(dbfile); }
/*---------------------------------------------------------------------- * Routine build_ucd3 * * Purpose * * Build a 3D ucd-mesh, ucd-var, facelist and zonelist, and return * the mesh ID. * * Arguments * name Name to assign mesh. * * Modifications * * Lisa J. Roberts, Fri Apr 7 10:48:31 PDT 2000 * Changed the prototype to ANSI standard and explicitly indicated * the function returns an int. Got rid of flid, zlid, varid, i, * ln, dbid, and matid, which were unused. * *--------------------------------------------------------------------*/ static int build_ucd3(DBfile *dbfile, char *name) { #define NZONES 3 /* Number of zones (elements) */ #define NFACES 14 /* Number of external faces */ #define NNODES 16 /* Number of mesh nodes */ #define NZSHAPES 1 /* Number of zone shapes */ #define NFSHAPES 1 /* Number of face shapes */ #define NFTYPES 0 /* Number of face types */ #define LZNODELIST 24 /* Length of zonelist nodelist */ #define LFNODELIST 56 /* Length of facelist nodelist */ /* Misc variables */ int meshid; int fshapesize, fshapecnt, zshapesize, zshapecnt; int idatatype; int dims; int inode, iface, izone, ifl, izl, nface = 0; #if 0 int mixlen = 0; int tcycle = 200; double ttime = 2.345; float *vars[3]; char *varnames[3]; DBfacelist *fl; #endif float *coords[3]; char *coordnames[3]; /* Coordinates */ float x[NNODES]; float y[NNODES]; float z[NNODES]; /* Nodal quantities */ static float u[NNODES] = {0., 0., 0., 0., .1, .1, .1, .1, .2, .2, .2, .2, .3, .3, .3, .3}; #if 0 static float v[NNODES] = {0., 0., 0., 0., .1, .1, .1, .1, .2, .2, .2, .2, .3, .3, .3, .3}; static float w[NNODES] = {0., 0., 0., 0., .1, .1, .1, .1, .2, .2, .2, .2, .3, .3, .3, .3}; #endif /* Zonal quantities */ static float d[NZONES] = {2., 4., 6.}; /* Material data */ static int matlist[NZONES] = {1, 1, 2}; static int matnos[2] = {1, 2}; /* Facelist data */ int fzoneno[NFACES]; int fnodelist[LFNODELIST]; /* Zonelist data */ int znodelist[LZNODELIST]; fshapesize = 4; fshapecnt = NFACES; zshapesize = 8; zshapecnt = NZONES; idatatype = DB_FLOAT; dims = NZONES; /*-------------------------------------------------- * Compute coordinate values, zonelist values, and * facelist values for a sample 3D mesh. *-------------------------------------------------*/ inode = 0; for (izone = 0; izone <= NZONES; izone++) { x[inode++] = 0.; x[inode++] = 1.; x[inode++] = 1.; x[inode++] = 0.; inode -= 4; y[inode++] = (float)izone; y[inode++] = (float)izone; y[inode++] = (float)izone; y[inode++] = (float)izone; inode -= 4; z[inode++] = 0.; z[inode++] = 0.; z[inode++] = 1.; z[inode++] = 1.; } izl = 0; for (izone = 0; izone < NZONES; izone++) { for (inode = 0; inode < 4; inode++) { znodelist[izl++] = izone * 4 + inode; } for (inode = 0; inode < 4; inode++) { znodelist[izl++] = (izone + 1) * 4 + inode; } } ifl = 0; for (izone = 0; izone < NZONES; izone++) { for (iface = 0; iface < 3; iface++) { fnodelist[ifl++] = izone * 4 + iface; fnodelist[ifl++] = izone * 4 + iface + 1; fnodelist[ifl++] = izone * 4 + iface + 5; fnodelist[ifl++] = izone * 4 + iface + 4; } fnodelist[ifl++] = izone * 4 + 3; fnodelist[ifl++] = izone * 4; fnodelist[ifl++] = izone * 4 + 4; fnodelist[ifl++] = izone * 4 + 7; for (iface = 0; iface < 4; iface++) fzoneno[nface++] = izone; } fnodelist[ifl++] = 0; fnodelist[ifl++] = 1; fnodelist[ifl++] = 2; fnodelist[ifl++] = 3; fzoneno[nface++] = 0; fnodelist[ifl++] = 12; fnodelist[ifl++] = 13; fnodelist[ifl++] = 14; fnodelist[ifl++] = 15; fzoneno[nface++] = NZONES - 1; #if 1 /*-------------------------------------------------- * Write out the external facelist we defined * above. *-------------------------------------------------*/ DBPutFacelist(dbfile, "fl", NFACES, 3, fnodelist, LFNODELIST, 0, fzoneno, &fshapesize, &fshapecnt, NFSHAPES, NULL, NULL, 0); #else /*-------------------------------------------------- * Calculate an external facelist from the zonelist * information. Write it out. *-------------------------------------------------*/ fl = (DBfacelist *) DBCalcExternalFacelist(znodelist, NNODES, 0, &zshapesize, &zshapecnt, NZSHAPES, matlist, 2); DBPutFacelist(dbfile, "fl", fl->nfaces, 3, fl->nodelist, fl->lnodelist, 0, fl->zoneno, fl->shapesize, fl->shapecnt, fl->nshapes, NULL, NULL, 0); #endif /*-------------------------------------------------- * Write out the zonelist. *-------------------------------------------------*/ DBSetDeprecateWarnings(0); DBPutZonelist(dbfile, "zl", NZONES, 3, znodelist, LZNODELIST, 0, &zshapesize, &zshapecnt, NZSHAPES); DBSetDeprecateWarnings(3); /*-------------------------------------------------- * Write out the mesh. *-------------------------------------------------*/ coords[0] = x; coords[1] = y; coords[2] = z; coordnames[0] = "X"; coordnames[1] = "Y"; coordnames[2] = "Z"; meshid = DBPutUcdmesh(dbfile, name, 3, (DBCAS_t) coordnames, coords, NNODES, NZONES, "zl", "fl", DB_FLOAT, NULL); /*-------------------------------------------------- * Write out the material data. *-------------------------------------------------*/ DBPutMaterial(dbfile, "material", name, 2, matnos, matlist, &dims, 1, NULL, NULL, NULL, NULL, 0, DB_FLOAT, NULL); /*-------------------------------------------------- * Write out a zonal variable. *-------------------------------------------------*/ DBPutUcdvar1(dbfile, "d", name, d, NZONES, NULL, 0, idatatype, DB_ZONECENT, NULL); /*-------------------------------------------------- * Write out a nodal variable. *-------------------------------------------------*/ DBPutUcdvar1(dbfile, "u", name, u, NNODES, NULL, 0, idatatype, DB_NODECENT, NULL); return (meshid); }