00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <string.h>
00004 #include <math.h>
00005 #if defined(_WIN32) && !defined(__NUTC__)
00006 # include <io.h>
00007 #else
00008 # include <unistd.h>
00009 #endif
00010 #include "cgnslib.h"
00011
00012 #define TWOPI 6.2831853
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 int CellDim = 3, PhyDim = 3;
00032
00033 int cgfile, cgbase, cgzone;
00034 int CellDim, PhyDim, size[9];
00035
00036 #define NUM_SIDE 5
00037 #define NODE_INDEX(I,J,K) ((I)+NUM_SIDE*(((J)-1)+NUM_SIDE*((K)-1)))
00038 #define CELL_INDEX(I,J,K) ((I)+(NUM_SIDE-1)*(((J)-1)+(NUM_SIDE-1)*((K)-1)))
00039
00040 int num_coord;
00041 float *xcoord, *ycoord, *zcoord;
00042 int num_element, *elements;
00043 int num_face, *faces, *parent;
00044
00045 int max_sol;
00046 float *solution;
00047
00048 int npts, *pts, *d_pts;
00049 float *interp;
00050
00051 char errmsg[128];
00052
00053 void init_data();
00054 void write_structured(), write_unstructured();
00055 void write_mixed(), write_mismatched();
00056
00057 void error_exit (char *where)
00058 {
00059 fprintf (stderr, "ERROR:%s:%s\n", where, cg_get_error());
00060 exit (1);
00061 }
00062
00063 int main (int argc, char *argv[])
00064 {
00065 char outfile[32];
00066
00067 strcpy (outfile, "test.cgns");
00068 if (argc > 1) {
00069 int type = 0;
00070 int n = 0;
00071 if (argv[1][n] == '-') n++;
00072 if (argv[1][n] == 'a' || argv[1][n] == 'A') {
00073 type = CG_FILE_ADF;
00074 strcpy (outfile, "test.cga");
00075 }
00076 else if (argv[1][n] == 'h' || argv[1][n] == 'H') {
00077 type = CG_FILE_HDF5;
00078 strcpy (outfile, "test.cgh");
00079 }
00080 else if (argv[1][n] == 'x' || argv[1][n] == 'X') {
00081 type = CG_FILE_XML;
00082 strcpy (outfile, "test.cgx");
00083 }
00084 else {
00085 fprintf(stderr, "unknown option\n");
00086 exit (1);
00087 }
00088 if (cg_set_file_type(type))
00089 error_exit("cg_set_file_type");
00090 }
00091 init_data();
00092 unlink(outfile);
00093 if (cg_open(outfile, CG_MODE_WRITE, &cgfile)) error_exit("cg_open");
00094 write_structured();
00095 write_unstructured();
00096 write_mixed();
00097 write_mismatched();
00098 if (cg_close(cgfile)) error_exit("cg_close");
00099 return 0;
00100 }
00101
00102 void init_data()
00103 {
00104 int n, i, j, k, nn, nf, np;
00105
00106
00107
00108 num_coord = NUM_SIDE * NUM_SIDE * NUM_SIDE;
00109 xcoord = (float *) malloc (6 * num_coord * sizeof(float));
00110 if (NULL == xcoord) {
00111 fprintf(stderr, "malloc failed for coordinates\n");
00112 exit(1);
00113 }
00114 ycoord = xcoord + 2 * num_coord;
00115 zcoord = ycoord + 2 * num_coord;
00116 for (n = 0, k = 0; k < NUM_SIDE; k++) {
00117 for (j = 0; j < NUM_SIDE; j++) {
00118 for (i = 0; i < NUM_SIDE; i++, n++) {
00119 xcoord[n] = (float)i;
00120 ycoord[n] = (float)j;
00121 zcoord[n] = (float)k;
00122 }
00123 }
00124 }
00125
00126
00127
00128 max_sol = (NUM_SIDE + 2) * (NUM_SIDE + 2) * (NUM_SIDE + 2);
00129 solution = (float *) malloc (max_sol * sizeof(float));
00130 if (NULL == solution) {
00131 fprintf(stderr, "malloc failed for solution\n");
00132 exit(1);
00133 }
00134 for (n = 0; n < max_sol; n++)
00135 solution[n] = (float)(n + 1);
00136
00137
00138
00139 num_element = (NUM_SIDE - 1) * (NUM_SIDE - 1) * (NUM_SIDE - 1);
00140 elements = (int *) malloc (8 * num_element * sizeof(int));
00141 if (NULL == elements) {
00142 fprintf(stderr, "malloc failed for elements");
00143 exit(1);
00144 }
00145 for (n = 0, k = 1; k < NUM_SIDE; k++) {
00146 for (j = 1; j < NUM_SIDE; j++) {
00147 for (i = 1; i < NUM_SIDE; i++) {
00148 nn = NODE_INDEX(i, j, k);
00149 elements[n++] = nn;
00150 elements[n++] = nn + 1;
00151 elements[n++] = nn + 1 + NUM_SIDE;
00152 elements[n++] = nn + NUM_SIDE;
00153 nn += NUM_SIDE * NUM_SIDE;
00154 elements[n++] = nn;
00155 elements[n++] = nn + 1;
00156 elements[n++] = nn + 1 + NUM_SIDE;
00157 elements[n++] = nn + NUM_SIDE;
00158 }
00159 }
00160 }
00161
00162
00163
00164 num_face = 6 * (NUM_SIDE - 1) * (NUM_SIDE - 1);
00165 faces = (int *) malloc (4 * num_face * sizeof(int));
00166 parent = (int *) malloc (4 * num_face * sizeof(int));
00167 if (NULL == faces || NULL == parent) {
00168 fprintf(stderr, "malloc failed for elements");
00169 exit(1);
00170 }
00171 for (n = 0; n < 4*num_face; n++)
00172 parent[n] = 0;
00173 nf = np = 0;
00174 n = 2 * num_face;
00175 i = 1;
00176 for (k = 1; k < NUM_SIDE; k++) {
00177 for (j = 1; j < NUM_SIDE; j++) {
00178 nn = NODE_INDEX(i, j, k);
00179 faces[nf++] = nn;
00180 faces[nf++] = nn + NUM_SIDE * NUM_SIDE;
00181 faces[nf++] = nn + NUM_SIDE * (NUM_SIDE + 1);
00182 faces[nf++] = nn + NUM_SIDE;
00183 parent[np] = CELL_INDEX(i, j, k);
00184 parent[np+n] = 5;
00185 np++;
00186 }
00187 }
00188 i = NUM_SIDE;
00189 for (k = 1; k < NUM_SIDE; k++) {
00190 for (j = 1; j < NUM_SIDE; j++) {
00191 nn = NODE_INDEX(i, j, k);
00192 faces[nf++] = nn;
00193 faces[nf++] = nn + NUM_SIDE;
00194 faces[nf++] = nn + NUM_SIDE * (NUM_SIDE + 1);
00195 faces[nf++] = nn + NUM_SIDE * NUM_SIDE;
00196 parent[np] = CELL_INDEX(i-1, j, k);
00197 parent[np+n] = 3;
00198 np++;
00199 }
00200 }
00201 j = 1;
00202 for (k = 1; k < NUM_SIDE; k++) {
00203 for (i = 1; i < NUM_SIDE; i++) {
00204 nn = NODE_INDEX(i, j, k);
00205 faces[nf++] = nn;
00206 faces[nf++] = nn + 1;
00207 faces[nf++] = nn + 1 + NUM_SIDE * NUM_SIDE;
00208 faces[nf++] = nn + NUM_SIDE * NUM_SIDE;
00209 parent[np] = CELL_INDEX(i, j, k);
00210 parent[np+n] = 2;
00211 np++;
00212 }
00213 }
00214 j = NUM_SIDE;
00215 for (k = 1; k < NUM_SIDE; k++) {
00216 for (i = 1; i < NUM_SIDE; i++) {
00217 nn = NODE_INDEX(i, j, k);
00218 faces[nf++] = nn;
00219 faces[nf++] = nn + NUM_SIDE * NUM_SIDE;
00220 faces[nf++] = nn + 1 + NUM_SIDE * NUM_SIDE;
00221 faces[nf++] = nn + 1;
00222 parent[np] = CELL_INDEX(i, j-1, k);
00223 parent[np+n] = 4;
00224 np++;
00225 }
00226 }
00227 k = 1;
00228 for (j = 1; j < NUM_SIDE; j++) {
00229 for (i = 1; i < NUM_SIDE; i++) {
00230 nn = NODE_INDEX(i, j, k);
00231 faces[nf++] = nn;
00232 faces[nf++] = nn + NUM_SIDE;
00233 faces[nf++] = nn + NUM_SIDE + 1;
00234 faces[nf++] = nn + 1;
00235 parent[np] = CELL_INDEX(i, j, k);
00236 parent[np+n] = 1;
00237 np++;
00238 }
00239 }
00240 k = NUM_SIDE;
00241 for (j = 1; j < NUM_SIDE; j++) {
00242 for (i = 1; i < NUM_SIDE; i++) {
00243 nn = NODE_INDEX(i, j, k);
00244 faces[nf++] = nn;
00245 faces[nf++] = nn + 1;
00246 faces[nf++] = nn + NUM_SIDE + 1;
00247 faces[nf++] = nn + NUM_SIDE;
00248 parent[np] = CELL_INDEX(i, j, k-1);
00249 parent[np+n] = 6;
00250 np++;
00251 }
00252 }
00253
00254
00255
00256 npts = NUM_SIDE * NUM_SIDE;
00257 pts = (int *) malloc (12 * npts * sizeof(int));
00258 if (NULL == pts) {
00259 fprintf(stderr, "malloc failed for connectivity points");
00260 exit(1);
00261 }
00262 d_pts = pts + 6 * npts;
00263
00264
00265
00266 interp = (float *) malloc (6 * npts * sizeof(float));
00267 if (NULL == interp) {
00268 fprintf(stderr, "malloc failed for interpolate array");
00269 exit(1);
00270 }
00271 }
00272
00273 void write_reference ()
00274 {
00275 int n, i, ierr, dim = 1;
00276 float exps[5];
00277
00278 static struct {
00279 char *name;
00280 int dim;
00281 int exps[5];
00282 float val;
00283 } state[] = {
00284 {"Mach", 0, {0, 0, 0, 0, 0}, 0.2},
00285 {"VelocitySound", 1, {0, 1, -1, 0, 0}, 330.0},
00286 {"VelocityMagnitude", 1, {0, 1, -1, 0, 0}, 66.0},
00287 {"VelocityUnitVectorX", 0, {0, 0, 0, 0, 0}, 1.0},
00288 {"VelocityUnitVectorY", 0, {0, 0, 0, 0, 0}, 0.0},
00289 {"VelocityUnitVectorZ", 0, {0, 0, 0, 0, 0}, 0.0},
00290 {"Reynolds", 0, {0, 0, 0, 0, 0}, 3.0e6},
00291 {"Temperature", 1, {0, 0, 0, 1, 0}, 300.0},
00292 {"Pressure", 1, {1, -1, -2, 0, 0}, 1.0e5},
00293 {"LengthReference", 1, {0, 1, 0, 0, 0}, 10.0}
00294 };
00295
00296 if (cg_goto(cgfile, cgbase, "end") ||
00297 cg_state_write("reference state quantities") ||
00298 cg_goto(cgfile, cgbase, "ReferenceState_t", 1, "end") ||
00299 cg_dataclass_write(Dimensional) ||
00300 cg_units_write(Kilogram, Meter, Second, Kelvin, Radian))
00301 error_exit("reference state");
00302
00303 for (n = 0; n < 10; n++) {
00304 if (cg_goto(cgfile, cgbase, "ReferenceState_t", 1, "end") ||
00305 cg_array_write(state[n].name, RealSingle, 1, &dim, &state[n].val) ||
00306 cg_goto(cgfile, cgbase, "ReferenceState_t", 1,
00307 "DataArray_t", n+1, "end")) {
00308 sprintf (errmsg, "reference state data %d", n+1);
00309 error_exit(errmsg);
00310 }
00311 if (state[n].dim) {
00312 for (i = 0; i < 5; i++)
00313 exps[i] = (float)state[n].exps[i];
00314 ierr = cg_exponents_write(RealSingle, exps);
00315 }
00316 else
00317 ierr = cg_dataclass_write(NondimensionalParameter);
00318 if (ierr) {
00319 sprintf (errmsg, "reference state data %d dataclass", n+1);
00320 error_exit(errmsg);
00321 }
00322 }
00323 }
00324
00325 void write_equationset ()
00326 {
00327 int n, diff[6], dim = 1;
00328 float g = 1.4;
00329 float R = 53.352;
00330 float ts = 110.6;
00331 float mu = 1.716e-5;
00332 float exp = 0.666;
00333 float pt = 0.9;
00334
00335 for (n = 0; n < 6; n++)
00336 diff[n] = 0;
00337 diff[2] = 1;
00338
00339
00340
00341 if (cg_goto(cgfile, cgbase, "end") ||
00342 cg_equationset_write (3) ||
00343 cg_goto(cgfile, cgbase, "FlowEquationSet_t", 1, "end") ||
00344 cg_governing_write(NSTurbulent) ||
00345 cg_model_write("GasModel_t", Ideal) ||
00346 cg_model_write("ViscosityModel_t", SutherlandLaw) ||
00347 cg_model_write("ThermalConductivityModel_t", PowerLaw) ||
00348 cg_model_write("TurbulenceClosure_t", EddyViscosity) ||
00349 cg_model_write("TurbulenceModel_t", Algebraic_BaldwinLomax))
00350 error_exit("flow equation set");
00351
00352 if (cg_dataclass_write(Dimensional) ||
00353 cg_units_write(Kilogram, Meter, Second, Kelvin, Radian))
00354 error_exit("flow equation set dataclass");
00355
00356
00357
00358 if (cg_goto(cgfile, cgbase, "FlowEquationSet_t", 1,
00359 "GoverningEquations_t", 1, "end") ||
00360 cg_diffusion_write(diff) ||
00361 cg_goto(cgfile, cgbase, "FlowEquationSet_t", 1,
00362 "TurbulenceModel_t", 1, "end") ||
00363 cg_diffusion_write(diff))
00364 error_exit("diffusion model");
00365
00366
00367
00368 if (cg_goto(cgfile, cgbase, "FlowEquationSet_t", 1,
00369 "GasModel_t", 1, "end") ||
00370 cg_dataclass_write(DimensionlessConstant) ||
00371 cg_array_write("SpecificHeatRatio", RealSingle, 1, &dim, &g) ||
00372 cg_array_write("IdealGasConstant", RealSingle, 1, &dim, &R) ||
00373 cg_goto(cgfile, cgbase, "FlowEquationSet_t", 1,
00374 "GasModel_t", 1, "DataArray_t", 2, "end") ||
00375 cg_dataclass_write(Dimensional) ||
00376 cg_units_write(Slug, Foot, Second, Rankine, Radian))
00377 error_exit("gas model");
00378
00379
00380
00381 if (cg_goto(cgfile, cgbase, "FlowEquationSet_t", 1,
00382 "ViscosityModel_t", 1, "end") ||
00383 cg_array_write("SutherlandLawConstant", RealSingle, 1, &dim, &ts) ||
00384 cg_array_write("ViscosityMolecularReference", RealSingle, 1, &dim, &mu))
00385 error_exit("viscosity model");
00386
00387
00388
00389 if (cg_goto(cgfile, cgbase, "FlowEquationSet_t", 1,
00390 "ThermalConductivityModel_t", 1, "end") ||
00391 cg_array_write("PowerLawExponent", RealSingle, 1, &dim, &exp) ||
00392 cg_goto(cgfile, cgbase, "FlowEquationSet_t", 1,
00393 "ThermalConductivityModel_t", 1, "DataArray_t", 1, "end") ||
00394 cg_dataclass_write(DimensionlessConstant))
00395 error_exit("thermal conductivity model");
00396
00397
00398
00399 if (cg_goto(cgfile, cgbase, "FlowEquationSet_t", 1,
00400 "TurbulenceClosure_t", 1, "end") ||
00401 cg_array_write("PrandtlTurbulent", RealSingle, 1, &dim, &pt) ||
00402 cg_goto(cgfile, cgbase, "FlowEquationSet_t", 1,
00403 "TurbulenceClosure_t", 1, "DataArray_t", 1, "end") ||
00404 cg_dataclass_write(DimensionlessConstant))
00405 error_exit("turbulence closure model");
00406 }
00407
00408 void write_coords(int nz)
00409 {
00410 int k, nn, n, nij, koff, cgcoord;
00411
00412 koff = nz == 1 ? 1 - NUM_SIDE : 0;
00413 nij = NUM_SIDE * NUM_SIDE;
00414 for (n = 0, k = 0; k < NUM_SIDE; k++) {
00415 for (nn = 0; nn < nij; nn++)
00416 zcoord[n++] = (float)(k + koff);
00417 }
00418
00419 if (cg_coord_write(cgfile, cgbase, nz, RealSingle,
00420 "CoordinateX", xcoord, &cgcoord) ||
00421 cg_coord_write(cgfile, cgbase, nz, RealSingle,
00422 "CoordinateY", ycoord, &cgcoord) ||
00423 cg_coord_write(cgfile, cgbase, nz, RealSingle,
00424 "CoordinateZ", zcoord, &cgcoord)) {
00425 sprintf (errmsg, "zone %d coordinates", nz);
00426 error_exit(errmsg);
00427 }
00428 }
00429
00430 void write_elements(int nz)
00431 {
00432 int cgsect;
00433
00434 if (cg_section_write(cgfile, cgbase, nz, "Elements", HEXA_8,
00435 1, num_element, 0, elements, &cgsect) ||
00436 cg_section_write(cgfile, cgbase, nz, "Faces", QUAD_4,
00437 num_element+1, num_element+num_face, 0, faces, &cgsect) ||
00438 cg_parent_data_write(cgfile, cgbase, nz, cgsect, parent)) {
00439 sprintf (errmsg, "zone %d elements", nz);
00440 error_exit(errmsg);
00441 }
00442 }
00443
00444 void write_zone_link(int nz, char *basename, char *nodename)
00445 {
00446 char pathname[128];
00447
00448 sprintf(pathname, "/%s/Zone%d/%s", basename, nz, nodename);
00449 if (cg_goto(cgfile, cgbase, "Zone_t", nz, "end") ||
00450 cg_link_write(nodename, "", pathname)) {
00451 sprintf (errmsg, "zone %d link", nz);
00452 error_exit(errmsg);
00453 }
00454 }
00455
00456
00457
00458
00459
00460 void write_structured()
00461 {
00462 int i, j, k, n, cgconn, cgbc, cgfam, cggeo, cgpart;
00463 int range[6], d_range[6], transform[3];
00464 int cgsol, rind[6], cgfld;
00465 char name[33];
00466
00467 printf ("writing structured base\n");
00468 fflush (stdout);
00469
00470 if (cg_base_write(cgfile, "Structured", CellDim, PhyDim, &cgbase) ||
00471 cg_goto(cgfile, cgbase, "end") ||
00472 cg_descriptor_write("Descriptor", "Multi-block Structured Grid") ||
00473 cg_dataclass_write(Dimensional) ||
00474 cg_units_write(Kilogram, Meter, Second, Kelvin, Radian))
00475 error_exit("structured base");
00476 if (cg_simulation_type_write(cgfile, cgbase, NonTimeAccurate))
00477 error_exit("simulation type");
00478
00479 write_reference();
00480 write_equationset();
00481
00482
00483
00484 for (n = 0; n < 3; n++) {
00485 size[n] = NUM_SIDE;
00486 size[n+3] = NUM_SIDE - 1;
00487 size[n+6] = 0;
00488 }
00489 for (n = 1; n <= 2; n++) {
00490 sprintf(name, "Zone%d", n);
00491 if (cg_zone_write(cgfile, cgbase, name, size, Structured, &cgzone)) {
00492 sprintf (errmsg, "structured zone %d", n);
00493 error_exit(errmsg);
00494 }
00495 write_coords(n);
00496 }
00497
00498
00499
00500 for (n = 0; n < 3; n++) {
00501 range[n] = d_range[n] = 1;
00502 range[n+3] = d_range[n+3] = NUM_SIDE;
00503 transform[n] = n + 1;
00504 }
00505 range[2] = NUM_SIDE;
00506 d_range[5] = 1;
00507 if (cg_1to1_write(cgfile, cgbase, 1, "1to1 -> Zone2", "Zone2",
00508 range, d_range, transform, &cgconn))
00509 error_exit("1to1->zone2");
00510
00511
00512
00513 for (n = 0; n < 3; n++) {
00514 range[n] = 1;
00515 range[n+3] = NUM_SIDE;
00516 }
00517 range[5] = 1;
00518 for (n = 0, j = 1; j <= NUM_SIDE; j++) {
00519 for (i = 1; i <= NUM_SIDE; i++) {
00520 d_pts[n++] = i;
00521 d_pts[n++] = j;
00522 d_pts[n++] = 1;
00523 }
00524 }
00525 if (cg_conn_write(cgfile, cgbase, 2, "Abutting1to1 -> Zone1",
00526 Vertex, Abutting1to1, PointRange, 2, range, "Zone1",
00527 Structured, PointListDonor, Integer, npts, d_pts, &cgconn))
00528 error_exit("abutting1to1->zone1");
00529
00530
00531
00532 for (n = 0; n < 3; n++) {
00533 range[n] = 1;
00534 range[n+3] = NUM_SIDE;
00535 }
00536 range[5] = 1;
00537 if (cg_boco_write(cgfile, cgbase, 1, "Inlet", BCInflow,
00538 PointRange, 2, range, &cgbc))
00539 error_exit("inlet boco");
00540
00541
00542
00543 for (n = 0, j = 1; j <= NUM_SIDE; j++) {
00544 for (i = 1; i <= NUM_SIDE; i++) {
00545 pts[n++] = i;
00546 pts[n++] = j;
00547 pts[n++] = NUM_SIDE;
00548 }
00549 }
00550 if (cg_boco_write(cgfile, cgbase, 2, "Outlet", BCOutflow,
00551 PointList, npts, pts, &cgbc))
00552 error_exit("outlet boco");
00553
00554
00555
00556 if (cg_family_write(cgfile, cgbase, "WallFamily", &cgfam) ||
00557 cg_fambc_write(cgfile, cgbase, cgfam, "WallBC", BCWall, &cgbc))
00558 error_exit("wall family bc");
00559
00560
00561
00562 if (cg_geo_write(cgfile, cgbase, cgfam, "Geometry",
00563 "geometry.file", "CADsystem", &cggeo) ||
00564 cg_part_write(cgfile, cgbase, cgfam, cggeo, "imin part", &cgpart) ||
00565 cg_part_write(cgfile, cgbase, cgfam, cggeo, "imax part", &cgpart) ||
00566 cg_part_write(cgfile, cgbase, cgfam, cggeo, "jmin part", &cgpart) ||
00567 cg_part_write(cgfile, cgbase, cgfam, cggeo, "jmax part", &cgpart))
00568 error_exit("wall family parts");
00569
00570 for (n = 0; n < 3; n++) {
00571 range[n] = 1;
00572 range[n+3] = NUM_SIDE;
00573 }
00574
00575 range[3] = 1;
00576 if (cg_boco_write(cgfile, cgbase, 1, "imin", FamilySpecified,
00577 PointRange, 2, range, &cgbc) ||
00578 cg_goto(cgfile, cgbase, "Zone_t", 1, "ZoneBC_t", 1,
00579 "BC_t", cgbc, "end") ||
00580 cg_famname_write("WallFamily"))
00581 error_exit("imin boco");
00582
00583 range[0] = range[3] = NUM_SIDE;
00584 if (cg_boco_write(cgfile, cgbase, 1, "imax", FamilySpecified,
00585 PointRange, 2, range, &cgbc) ||
00586 cg_goto(cgfile, cgbase, "Zone_t", 1, "ZoneBC_t", 1,
00587 "BC_t", cgbc, "end") ||
00588 cg_famname_write("WallFamily"))
00589 error_exit("imax boco");
00590
00591 range[0] = range[4] = 1;
00592 if (cg_boco_write(cgfile, cgbase, 1, "jmin", FamilySpecified,
00593 PointRange, 2, range, &cgbc) ||
00594 cg_goto(cgfile, cgbase, "Zone_t", 1, "ZoneBC_t", 1,
00595 "BC_t", cgbc, "end") ||
00596 cg_famname_write("WallFamily"))
00597 error_exit("jmin boco");
00598
00599 range[1] = range[4] = NUM_SIDE;
00600 if (cg_boco_write(cgfile, cgbase, 1, "jmax", FamilySpecified,
00601 PointRange, 2, range, &cgbc) ||
00602 cg_goto(cgfile, cgbase, "Zone_t", 1, "ZoneBC_t", 1,
00603 "BC_t", cgbc, "end") ||
00604 cg_famname_write("WallFamily"))
00605 error_exit("jmax boco");
00606
00607
00608
00609 for (n = 0, k = 1; k <= NUM_SIDE; k++) {
00610 for (i = 1; i < NUM_SIDE; i++) {
00611 pts[n++] = i + 1;
00612 pts[n++] = 1;
00613 pts[n++] = k;
00614 pts[n++] = i;
00615 pts[n++] = NUM_SIDE;
00616 pts[n++] = k;
00617 }
00618 for (j = 1; j < NUM_SIDE; j++) {
00619 pts[n++] = 1;
00620 pts[n++] = j;
00621 pts[n++] = k;
00622 pts[n++] = NUM_SIDE;
00623 pts[n++] = j+1;
00624 pts[n++] = k;
00625 }
00626 }
00627 if (cg_boco_write(cgfile, cgbase, 2, "Walls", BCWall,
00628 PointList, n / 3, pts, &cgbc))
00629 error_exit("zone 2 walls boco");
00630
00631
00632
00633 for (n = 0; n < 6; n++)
00634 rind[n] = 1;
00635 if (cg_sol_write(cgfile, cgbase, 1, "VertexSolution", Vertex, &cgsol) ||
00636 cg_goto(cgfile, cgbase, "Zone_t", 1, "FlowSolution_t", cgsol, "end") ||
00637 cg_rind_write(rind) ||
00638 cg_field_write(cgfile, cgbase, 1, cgsol, RealSingle,
00639 "Density", solution, &cgfld))
00640 error_exit("zone 1 solution");
00641
00642
00643
00644 rind[0] = rind[1] = 0;
00645 if (cg_sol_write(cgfile, cgbase, 2, "CellCenterSolution",
00646 CellCenter, &cgsol) ||
00647 cg_goto(cgfile, cgbase, "Zone_t", 2, "FlowSolution_t", cgsol, "end") ||
00648 cg_rind_write(rind) ||
00649 cg_field_write(cgfile, cgbase, 2, cgsol, RealSingle,
00650 "Density", solution, &cgfld))
00651 error_exit("zone 2 solution");
00652 }
00653
00654
00655
00656
00657
00658 void write_unstructured()
00659 {
00660 int n, nelem, cgconn, cgbc;
00661 int range[2];
00662 int cgsol, cgfld;
00663 char name[33];
00664 #ifdef UNSTRUCTURED_1TO1
00665 int d_range[2], transform;
00666 #else
00667 # ifdef ABUTTING1TO1_FACES
00668 GridLocation_t location;
00669 # else
00670 int i, j;
00671 # endif
00672 #endif
00673
00674 printf ("writing unstructured base\n");
00675 fflush (stdout);
00676
00677 if (cg_base_write(cgfile, "Unstructured", CellDim, PhyDim, &cgbase) ||
00678 cg_goto(cgfile, cgbase, "end") ||
00679 cg_descriptor_write("Descriptor", "Multi-block Unstructured Grid") ||
00680 cg_dataclass_write(NormalizedByDimensional) ||
00681 cg_units_write(Kilogram, Meter, Second, Kelvin, Radian))
00682 error_exit("unstructured base");
00683
00684
00685
00686 for (n = 0; n < 9; n++)
00687 size[n] = 0;
00688 size[0] = num_coord;
00689 size[1] = num_element;
00690 for (n = 1; n <= 2; n++) {
00691 sprintf(name, "Zone%d", n);
00692 if (cg_zone_write(cgfile, cgbase, name, size, Unstructured, &cgzone)) {
00693 sprintf (errmsg, "unstructured zone %d", n);
00694 error_exit(errmsg);
00695 }
00696 write_coords(n);
00697 write_elements(n);
00698 }
00699 nelem = (NUM_SIDE - 1) * (NUM_SIDE - 1);
00700
00701 #ifdef UNSTRUCTURED_1TO1
00702
00703
00704
00705 range[0] = NODE_INDEX(1, 1, NUM_SIDE);
00706 range[1] = NODE_INDEX(NUM_SIDE, NUM_SIDE, NUM_SIDE);
00707 d_range[0] = NODE_INDEX(1, 1, 1);
00708 d_range[1] = NODE_INDEX(NUM_SIDE, NUM_SIDE, 1);
00709 transform = 1;
00710 if (cg_1to1_write(cgfile, cgbase, 1, "1to1 -> Zone2", "Zone2",
00711 range, d_range, &transform, &cgconn))
00712 error_exit("1to1->zone2");
00713
00714 if (cg_1to1_write(cgfile, cgbase, 2, "1to1 -> Zone1", "Zone1",
00715 d_range, range, &transform, &cgconn))
00716 error_exit("1to1->zone1");
00717
00718 #else
00719 # ifdef ABUTTING1TO1_FACES
00720
00721
00722
00723 range[0] = num_element + num_face - nelem + 1;
00724 range[1] = num_element + num_face;
00725 for (n = 0; n < nelem; n++)
00726 d_pts[n] = range[0] + n - nelem;
00727
00728 location = FaceCenter;
00729
00730
00731 if (cg_conn_write(cgfile, cgbase, 1, "Abutting1to1 -> Zone2",
00732 location, Abutting1to1, PointRange, 2, range, "Zone2",
00733 Unstructured, PointListDonor, Integer, nelem, d_pts, &cgconn))
00734 error_exit("face center abutting1to1->zone2");
00735
00736
00737
00738 for (n = 0; n < nelem; n++) {
00739 pts[n] = num_element + num_face - 2 * nelem + 1 + n;
00740 d_pts[n] = pts[n] + nelem;
00741 }
00742 if (cg_conn_write(cgfile, cgbase, 2, "Abutting1to1 -> Zone1",
00743 location, Abutting1to1, PointList, nelem, pts, "Zone1",
00744 Unstructured, PointListDonor, Integer, nelem, d_pts, &cgconn))
00745 error_exit("face center abutting1to1->zone1");
00746
00747 # else
00748
00749
00750
00751 range[0] = NODE_INDEX(1, 1, NUM_SIDE);
00752 range[1] = NODE_INDEX(NUM_SIDE, NUM_SIDE, NUM_SIDE);
00753 for (n = 0, j = 1; j <= NUM_SIDE; j++) {
00754 for (i = 1; i <= NUM_SIDE; i++)
00755 d_pts[n++] = NODE_INDEX(i, j, 1);
00756 }
00757 if (cg_conn_write(cgfile, cgbase, 1, "Abutting1to1 -> Zone2",
00758 Vertex, Abutting1to1, PointRange, 2, range, "Zone2",
00759 Unstructured, PointListDonor, Integer, npts, d_pts, &cgconn))
00760 error_exit("point range abutting1to1->zone2");
00761
00762
00763
00764 for (n = 0, j = 1; j <= NUM_SIDE; j++) {
00765 for (i = 1; i <= NUM_SIDE; i++) {
00766 pts[n] = d_pts[n];
00767 d_pts[n++] = NODE_INDEX(i, j, NUM_SIDE);
00768 }
00769 }
00770 if (cg_conn_write(cgfile, cgbase, 2, "Abutting1to1 -> Zone1",
00771 Vertex, Abutting1to1, PointList, npts, pts, "Zone1",
00772 Unstructured, PointListDonor, Integer, npts, d_pts, &cgconn))
00773 error_exit("point list abutting1to1->zone1");
00774
00775 # endif
00776 #endif
00777
00778
00779
00780
00781 range[0] = num_element + 1;
00782 range[1] = num_element + 4 * nelem;
00783 for (n = 0; n < nelem; n++) {
00784 pts[n] = num_element + num_face - 2 * nelem + 1 + n;
00785 d_pts[n] = pts[n] + nelem;
00786 }
00787
00788 if (cg_boco_write(cgfile, cgbase, 1, "Inlet", BCInflow,
00789 ElementList, nelem, pts, &cgbc))
00790 error_exit ("elementlist inlet boco");
00791 if (cg_boco_write(cgfile, cgbase, 2, "Outlet", BCOutflow,
00792 ElementList, nelem, d_pts, &cgbc))
00793 error_exit ("elementlist outlet boco");
00794 if (cg_boco_write(cgfile, cgbase, 1, "Walls", BCWall,
00795 ElementRange, 2, range, &cgbc))
00796 error_exit ("elementrange zone 1 walls boco");
00797 if (cg_boco_write(cgfile, cgbase, 2, "Walls", BCWall,
00798 ElementRange, 2, range, &cgbc))
00799 error_exit ("elementrange zone 2 walls boco");
00800
00801
00802
00803 if (cg_sol_write(cgfile, cgbase, 1, "VertexSolution", Vertex, &cgsol) ||
00804 cg_field_write(cgfile, cgbase, 1, cgsol, RealSingle,
00805 "Density", solution, &cgfld))
00806 error_exit("zone 1 solution");
00807 if (cg_sol_write(cgfile, cgbase, 2, "CellCenterSolution",
00808 CellCenter, &cgsol) ||
00809 cg_field_write(cgfile, cgbase, 2, cgsol, RealSingle,
00810 "Density", solution, &cgfld))
00811 error_exit("zone 2 solution");
00812 }
00813
00814
00815
00816
00817
00818 void write_mixed()
00819 {
00820 int i, j, k, n, nelem, cgconn, cgbc;
00821 int range[6];
00822 #ifdef ABUTTING1TO1_FACES
00823 GridLocation_t location;
00824 #endif
00825
00826 printf ("writing mixed base\n");
00827 fflush (stdout);
00828
00829 if (cg_base_write(cgfile, "Mixed", CellDim, PhyDim, &cgbase) ||
00830 cg_goto(cgfile, cgbase, "end") ||
00831 cg_descriptor_write("Descriptor",
00832 "Mixed Structured and Unstructured Grid") ||
00833 cg_dataclass_write(Dimensional) ||
00834 cg_units_write(Kilogram, Meter, Second, Kelvin, Radian))
00835 error_exit("mixed base");
00836
00837
00838
00839 for (n = 0; n < 3; n++) {
00840 size[n] = NUM_SIDE;
00841 size[n+3] = NUM_SIDE - 1;
00842 size[n+6] = 0;
00843 }
00844 if (cg_zone_write(cgfile, cgbase, "StructuredZone", size,
00845 Structured, &cgzone))
00846 error_exit("structured zone");
00847 write_zone_link(1, "Structured", "GridCoordinates");
00848
00849
00850
00851 for (n = 0; n < 9; n++)
00852 size[n] = 0;
00853 size[0] = num_coord;
00854 size[1] = num_element;
00855 if (cg_zone_write(cgfile, cgbase, "UnstructuredZone", size,
00856 Unstructured, &cgzone))
00857 error_exit("unstructured zone");
00858 write_zone_link(2, "Unstructured", "GridCoordinates");
00859 write_zone_link(2, "Unstructured", "Elements");
00860 write_zone_link(2, "Unstructured", "Faces");
00861 nelem = (NUM_SIDE - 1) * (NUM_SIDE - 1);
00862
00863 #ifdef ABUTTING1TO1_FACES
00864
00865
00866
00867 for (n = 0; n < 3; n++) {
00868 range[n] = 1;
00869 range[n+3] = NUM_SIDE - 1;
00870 }
00871 range[2] = range[5] = NUM_SIDE;
00872 for (n = 0; n < nelem; n++)
00873 d_pts[n] = num_element + num_face - 2 * nelem + 1 + n;
00874
00875 location = KFaceCenter;
00876 if (cg_conn_write(cgfile, cgbase, 1, "Structured -> Unstructured",
00877 location, Abutting1to1, PointRange, 2, range, "UnstructuredZone",
00878 Unstructured, PointListDonor, Integer, nelem, d_pts, &cgconn))
00879 error_exit("abutting1to1->unstructured face range");
00880
00881 #else
00882
00883
00884
00885 for (n = 0; n < 3; n++) {
00886 range[n] = 1;
00887 range[n+3] = NUM_SIDE;
00888 }
00889 range[2] = NUM_SIDE;
00890 for (n = 0; n < npts; n++)
00891 d_pts[n] = n + 1;
00892 if (cg_conn_write(cgfile, cgbase, 1, "Structured -> Unstructured",
00893 Vertex, Abutting1to1, PointRange, 2, range, "UnstructuredZone",
00894 Unstructured, PointListDonor, Integer, npts, d_pts, &cgconn))
00895 error_exit("abutting1to1->unstructured point range");
00896
00897 #endif
00898
00899
00900
00901 range[0] = 1;
00902 range[1] = npts;
00903 for (n = 0, j = 1; j <= NUM_SIDE; j++) {
00904 for (i = 1; i <= NUM_SIDE; i++) {
00905 d_pts[n++] = i;
00906 d_pts[n++] = j;
00907 d_pts[n++] = NUM_SIDE;
00908 }
00909 }
00910 if (cg_conn_write(cgfile, cgbase, 2, "Unstructured -> Structured",
00911 Vertex, Abutting1to1, PointRange, 2, range, "StructuredZone",
00912 Structured, PointListDonor, Integer, npts, d_pts, &cgconn))
00913 error_exit("abutting1to1->structured point range");
00914
00915 #ifdef STRUCTURED_FACES
00916
00917
00918
00919 for (n = 0; n < 3; n++) {
00920 range[n] = 1;
00921 range[n+3] = NUM_SIDE - 1;
00922 }
00923 range[5] = 1;
00924 if (cg_boco_write(cgfile, cgbase, 1, "Inlet", BCInflow,
00925 PointRange, 2, range, &cgbc) ||
00926 cg_goto(cgfile, cgbase, "Zone_t", 1, "ZoneBC_t", 1,
00927 "BC_t", cgbc, "end") ||
00928 cg_gridlocation_write(KFaceCenter))
00929 error_exit("kfacecenter inlet boco");
00930
00931 #else
00932
00933
00934
00935 for (n = 0; n < 3; n++) {
00936 range[n] = 1;
00937 range[n+3] = NUM_SIDE;
00938 }
00939 range[5] = 1;
00940 if (cg_boco_write(cgfile, cgbase, 1, "Inlet", BCInflow,
00941 PointRange, 2, range, &cgbc))
00942 error_exit("point range inlet boco");
00943
00944 #endif
00945
00946
00947
00948 range[0] = num_coord - npts + 1;
00949 range[1] = num_coord;
00950 if (cg_boco_write(cgfile, cgbase, 2, "Outlet", BCOutflow,
00951 PointRange, 2, range, &cgbc))
00952 error_exit("point range outlet boco");
00953
00954 #ifdef STRUCTURED_FACES
00955
00956
00957
00958 for (n = 0, k = 1; k < NUM_SIDE; k++) {
00959 for (i = 1; i < NUM_SIDE; i++) {
00960 pts[n++] = i;
00961 pts[n++] = 1;
00962 pts[n++] = k;
00963 pts[n++] = i;
00964 pts[n++] = NUM_SIDE;
00965 pts[n++] = k;
00966 }
00967 for (j = 1; j < NUM_SIDE; j++) {
00968 pts[n++] = 1;
00969 pts[n++] = j;
00970 pts[n++] = k;
00971 pts[n++] = NUM_SIDE;
00972 pts[n++] = j;
00973 pts[n++] = k;
00974 }
00975 }
00976 if (cg_boco_write(cgfile, cgbase, 1, "Walls", BCWall,
00977 PointList, 4 * nelem, pts, &cgbc) ||
00978 cg_goto(cgfile, cgbase, "Zone_t", 1, "ZoneBC_t", 1,
00979 "BC_t", cgbc, "end") ||
00980 cg_gridlocation_write(FaceCenter))
00981 error_exit("face list zone 1 walls boco");
00982
00983 #else
00984
00985
00986
00987 for (n = 0, k = 1; k <= NUM_SIDE; k++) {
00988 for (i = 1; i < NUM_SIDE; i++) {
00989 pts[n++] = i + 1;
00990 pts[n++] = 1;
00991 pts[n++] = k;
00992 pts[n++] = i;
00993 pts[n++] = NUM_SIDE;
00994 pts[n++] = k;
00995 }
00996 for (j = 1; j < NUM_SIDE; j++) {
00997 pts[n++] = 1;
00998 pts[n++] = j;
00999 pts[n++] = k;
01000 pts[n++] = NUM_SIDE;
01001 pts[n++] = j+1;
01002 pts[n++] = k;
01003 }
01004 }
01005 if (cg_boco_write(cgfile, cgbase, 1, "Walls", BCWall,
01006 PointList, n / 3, pts, &cgbc))
01007 error_exit("point list zone 1 walls boco");
01008
01009 #endif
01010
01011
01012
01013 for (n = 0, k = 1; k <= NUM_SIDE; k++) {
01014 for (i = 1; i < NUM_SIDE; i++) {
01015 pts[n++] = NODE_INDEX(i + 1, 1, k);
01016 pts[n++] = NODE_INDEX(i, NUM_SIDE, k);
01017 }
01018 for (j = 1; j < NUM_SIDE; j++) {
01019 pts[n++] = NODE_INDEX(1, j, k);
01020 pts[n++] = NODE_INDEX(NUM_SIDE, j + 1, k);
01021 }
01022 }
01023 if (cg_boco_write(cgfile, cgbase, 2, "Walls", BCWall,
01024 PointList, n, pts, &cgbc))
01025 error_exit("point list zone 2 walls boco");
01026 }
01027
01028
01029
01030
01031
01032 void write_mismatched()
01033 {
01034 int i, j, k, n, nj, cgcoord, cgconn, cgbc;
01035 int ic, jc, dims[2];
01036 float dx, dy, dtheta, r, t, x, y;
01037 int range[6], d_range[6], transform[3];
01038 PointSetType_t d_type;
01039
01040 printf ("writing mismatched base\n");
01041 fflush (stdout);
01042
01043 if (cg_base_write(cgfile, "Mismatched", CellDim, PhyDim, &cgbase) ||
01044 cg_goto(cgfile, cgbase, "end") ||
01045 cg_descriptor_write("Descriptor", "Mismatched Grid") ||
01046 cg_dataclass_write(Dimensional) ||
01047 cg_units_write(Kilogram, Meter, Second, Kelvin, Radian))
01048 error_exit("mismatched base");
01049
01050
01051
01052 for (n = 0; n < 3; n++) {
01053 size[n] = NUM_SIDE;
01054 size[n+3] = NUM_SIDE - 1;
01055 size[n+6] = 0;
01056 }
01057
01058 dx = 0.5 * (float)(NUM_SIDE - 1);
01059 dy = 0.5 * (float)(NUM_SIDE - 1);
01060 for (n = 0, k = 0; k < NUM_SIDE; k++) {
01061 for (j = 0; j < NUM_SIDE; j++) {
01062 for (i = 0; i < NUM_SIDE; i++, n++) {
01063 xcoord[n] -= dx;
01064 ycoord[n] -= dy;
01065 }
01066 }
01067 }
01068 if (cg_zone_write(cgfile, cgbase, "CartesianZone", size,
01069 Structured, &cgzone))
01070 error_exit("cartesion zone");
01071 write_coords(1);
01072
01073
01074
01075 nj = 2 * NUM_SIDE;
01076 dtheta = (float)TWOPI / (float)(nj - 1);
01077 for (n = 0, k = 0; k < NUM_SIDE; k++) {
01078 for (j = 0; j < nj; j++) {
01079 for (i = 0; i < NUM_SIDE; i++, n++) {
01080 xcoord[n] = (float)i;
01081 ycoord[n] = (float)j * dtheta;
01082 zcoord[n] = (float)k;
01083 }
01084 }
01085 }
01086 size[1] = nj;
01087 size[4] = nj - 1;
01088 if (cg_zone_write(cgfile, cgbase, "CylindricalZone", size,
01089 Structured, &cgzone) ||
01090 cg_coord_write(cgfile, cgbase, cgzone, RealSingle,
01091 "CoordinateR", xcoord, &cgcoord) ||
01092 cg_coord_write(cgfile, cgbase, cgzone, RealSingle,
01093 "CoordinateTheta", ycoord, &cgcoord) ||
01094 cg_coord_write(cgfile, cgbase, cgzone, RealSingle,
01095 "CoordinateZ", zcoord, &cgcoord))
01096 error_exit("cylindrical zone");
01097
01098
01099
01100 for (n = 0, j = 0; j < NUM_SIDE; j++) {
01101 for (i = 0; i < NUM_SIDE; i++) {
01102 x = (float)i - dx;
01103 y = (float)j - dy;
01104 r = (float)sqrt (x * x + y * y);
01105 if (r > (float)(NUM_SIDE - 1)) continue;
01106 ic = (int)r;
01107 if (ic >= NUM_SIDE - 1) ic = NUM_SIDE - 2;
01108 t = (float)atan2 (y, x);
01109 if (t < 0.0) t += (float)TWOPI;
01110 jc = (int)(t / dtheta);
01111 if (jc >= nj - 1) jc = nj - 2;
01112 pts[n] = i + 1;
01113 pts[n+1] = j + 1;
01114 pts[n+2] = NUM_SIDE;
01115 d_pts[n] = ic + 1;
01116 d_pts[n+1] = jc + 1;
01117 d_pts[n+2] = 1;
01118 interp[n++] = r - (float)ic;
01119 interp[n++] = t / dtheta - (float)jc;
01120 interp[n++] = 0.0;
01121 }
01122 }
01123
01124 dims[0] = 3;
01125 dims[1] = n / 3;
01126 d_type = CellListDonor;
01127 if (cg_conn_write(cgfile, cgbase, 1, "Cartesian -> Cylindrical",
01128 Vertex, Abutting, PointList, n/3, pts, "CylindricalZone",
01129 Structured, d_type, Integer, n/3, d_pts, &cgconn) ||
01130 cg_goto(cgfile, cgbase, "Zone_t", 1, "ZoneGridConnectivity_t", 1,
01131 "GridConnectivity_t", cgconn, "end") ||
01132 cg_array_write("InterpolantsDonor", RealSingle, 2, dims, interp))
01133 error_exit("cartesian->cylindrical connectivity");
01134
01135
01136
01137 for (n = 0, j = 0; j < nj; j++) {
01138 for (i = 0; i < NUM_SIDE; i++) {
01139 r = (float)i;
01140 t = (float)j * dtheta;
01141 x = r * (float)cos (t) + dx;
01142 y = r * (float)sin (t) + dy;
01143 if (x < 0.0 || x > (float)(NUM_SIDE - 1) ||
01144 y < 0.0 || y > (float)(NUM_SIDE - 1)) continue;
01145 ic = (int)x;
01146 if (ic >= NUM_SIDE - 1) ic = NUM_SIDE - 2;
01147 jc = (int)y;
01148 if (jc >= NUM_SIDE - 1) jc = NUM_SIDE - 2;
01149 pts[n] = i + 1;
01150 pts[n+1] = j + 1;
01151 pts[n+2] = 1;
01152 d_pts[n] = ic + 1;
01153 d_pts[n+1] = jc + 1;
01154 d_pts[n+2] = NUM_SIDE;
01155 interp[n++] = x - (float)ic;
01156 interp[n++] = y - (float)jc;
01157 interp[n++] = 0.0;
01158 }
01159 }
01160
01161 dims[0] = 3;
01162 dims[1] = n / 3;
01163 d_type = CellListDonor;
01164 if (cg_conn_write(cgfile, cgbase, 2, "Cylindrical -> Cartesian",
01165 Vertex, Abutting, PointList, n/3, pts, "CartesianZone",
01166 Structured, d_type, Integer, n/3, d_pts, &cgconn) ||
01167 cg_goto(cgfile, cgbase, "Zone_t", 2, "ZoneGridConnectivity_t", 1,
01168 "GridConnectivity_t", cgconn, "end") ||
01169 cg_array_write("InterpolantsDonor", RealSingle, 2, dims, interp))
01170 error_exit("cylindrical->cartesian connectivity");
01171
01172
01173
01174 for (n = 0; n < 3; n++) {
01175 transform[n] = n + 1;
01176 range[n] = d_range[n] = 1;
01177 range[n+3] = d_range[n+3] = NUM_SIDE;
01178 }
01179 range[4] = 1;
01180 d_range[1] = d_range[4] = nj;
01181 if (cg_1to1_write(cgfile, cgbase, 2, "Periodic", "CylindricalZone",
01182 range, d_range, transform, &cgconn))
01183 error_exit("periodic 1to1");
01184
01185
01186
01187 range[4] = NUM_SIDE;
01188 range[5] = 1;
01189 if (cg_boco_write(cgfile, cgbase, 1, "Inlet", BCInflow,
01190 PointRange, 2, range, &cgbc))
01191 error_exit("inlet boco");
01192
01193
01194
01195 range[4] = nj;
01196 range[2] = range[5] = NUM_SIDE;
01197 if (cg_boco_write(cgfile, cgbase, 2, "Outlet", BCOutflow,
01198 PointRange, 2, range, &cgbc))
01199 error_exit("outlet boco");
01200
01201
01202
01203 for (n = 0, k = 1; k <= NUM_SIDE; k++) {
01204 for (i = 1; i < NUM_SIDE; i++) {
01205 pts[n++] = i + 1;
01206 pts[n++] = 1;
01207 pts[n++] = k;
01208 pts[n++] = i;
01209 pts[n++] = NUM_SIDE;
01210 pts[n++] = k;
01211 }
01212 for (j = 1; j < NUM_SIDE; j++) {
01213 pts[n++] = 1;
01214 pts[n++] = j;
01215 pts[n++] = k;
01216 pts[n++] = NUM_SIDE;
01217 pts[n++] = j+1;
01218 pts[n++] = k;
01219 }
01220 }
01221 if (cg_boco_write(cgfile, cgbase, 1, "Walls", BCWall,
01222 PointList, n/3, pts, &cgbc))
01223 error_exit("zone 1 walls boco");
01224
01225
01226
01227 for (n = 0, k = 1; k <= NUM_SIDE; k++) {
01228 for (j = 1; j <= nj; j++) {
01229 pts[n++] = NUM_SIDE;
01230 pts[n++] = j;
01231 pts[n++] = k;
01232 }
01233 }
01234 if (cg_boco_write(cgfile, cgbase, 2, "Walls", BCWall,
01235 PointList, n/3, pts, &cgbc))
01236 error_exit("zone 2 walls boco");
01237 }
01238