PageRenderTime 48ms CodeModel.GetById 2ms app.highlight 39ms RepoModel.GetById 1ms app.codeStats 0ms

/contrib/exodusii/5.22b/exodus/cbind/test/testwt_nossnsdf.c

https://bitbucket.org/vijaysm/libmesh
C | 889 lines | 481 code | 193 blank | 215 comment | 18 complexity | 7f42ea08b42fd2777074d89ac1b57121 MD5 | raw file
  1/*
  2 * Copyright (c) 2005 Sandia Corporation. Under the terms of Contract
  3 * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Governement
  4 * retains certain rights in this software.
  5 * 
  6 * Redistribution and use in source and binary forms, with or without
  7 * modification, are permitted provided that the following conditions are
  8 * met:
  9 * 
 10 *     * Redistributions of source code must retain the above copyright
 11 *       notice, this list of conditions and the following disclaimer.
 12 * 
 13 *     * Redistributions in binary form must reproduce the above
 14 *       copyright notice, this list of conditions and the following
 15 *       disclaimer in the documentation and/or other materials provided
 16 *       with the distribution.  
 17 * 
 18 *     * Neither the name of Sandia Corporation nor the names of its
 19 *       contributors may be used to endorse or promote products derived
 20 *       from this software without specific prior written permission.
 21 * 
 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 33 * 
 34 */
 35/*****************************************************************************
 36*
 37* testwt1 - test write an ExodusII database file
 38*
 39* author - Sandia National Laboratories
 40*          Larry A. Schoof - Original
 41*          Vic Yarberry    - Added headers and error logging
 42*               7/7/93          Modified for use with Exodus 2.00
 43*
 44*          
 45* environment - UNIX
 46*
 47* entry conditions - 
 48*
 49* exit conditions - 
 50*
 51* revision history - 
 52*
 53*  This is a test program for the C binding of the EXODUS II 
 54*  database write routines.
 55*
 56*
 57*****************************************************************************/
 58
 59
 60#include <stdlib.h>
 61#include <stdio.h>
 62#include "netcdf.h"
 63#include "exodusII.h"
 64
 65int main (int argc, char **argv)
 66{
 67   int exoid, num_dim, num_nodes, num_elem, num_elem_blk;
 68   int num_elem_in_block[10], num_nodes_per_elem[10], num_attr[10];
 69   int num_node_sets, num_side_sets, error;
 70   int i, j, k, m, *elem_map, *connect, *node_map;
 71   int node_list[100],elem_list[100],side_list[100];
 72   int ebids[10], ids[10];
 73   int num_nodes_per_set[10], num_elem_per_set[10];
 74   int num_df_per_set[10];
 75   int df_ind[10], node_ind[10], elem_ind[10];
 76   int  num_qa_rec, num_info;
 77   int num_glo_vars, num_nod_vars, num_ele_vars;
 78   int *truth_tab;
 79   int whole_time_step, num_time_steps;
 80   int CPU_word_size,IO_word_size;
 81   int prop_array[2];
 82
 83   float *glob_var_vals, *nodal_var_vals, *elem_var_vals;
 84   float time_value;
 85   float x[100], y[100], z[100];
 86   float attrib[100], dist_fact[100];
 87   char *coord_names[3], *qa_record[2][4], *info[3], *var_names[3];
 88   char *prop_names[2];
 89
 90   ex_opts (EX_VERBOSE | EX_ABORT);
 91
 92/* Specify compute and i/o word size */
 93
 94   CPU_word_size = 0;                   /* float or double */
 95   IO_word_size = 0;                    /* use system default (4 bytes) */
 96
 97/* create EXODUS II file */
 98
 99   exoid = ex_create ("test.exo",       /* filename path */
100                       EX_CLOBBER,      /* create mode */
101                       &CPU_word_size,  /* CPU float word size in bytes */
102                       &IO_word_size);  /* I/O float word size in bytes */
103   printf ("after ex_create for test.exo, exoid = %d\n", exoid);
104   printf (" cpu word size: %d io word size: %d\n",CPU_word_size,IO_word_size);
105
106   /* ncopts = NC_VERBOSE; */
107
108/* initialize file with parameters */
109
110   num_dim = 3;
111   num_nodes = 28;
112   num_elem = 8;
113   num_elem_blk = 7;
114   num_node_sets = 2;
115   num_side_sets = 5;
116   /* num_side_sets = 6; Uncomment to test NULL side sets */
117
118   error = ex_put_init (exoid, "This is testwt1", num_dim, num_nodes, num_elem,
119                        num_elem_blk, num_node_sets, num_side_sets);
120
121   printf ("after ex_put_init, error = %d\n", error);
122
123/* write nodal coordinates values and names to database */
124
125/* Quad #1 */
126   x[0] = 0.0; y[0] = 0.0; z[0] = 0.0;
127   x[1] = 1.0; y[1] = 0.0; z[1] = 0.0;
128   x[2] = 1.0; y[2] = 1.0; z[2] = 0.0;
129   x[3] = 0.0; y[3] = 1.0; z[3] = 0.0;
130
131/* Quad #2 */
132   x[4]  =  1.0; y[4]  =  0.0; z[4]  =  0.0;
133   x[5]  =  2.0; y[5]  =  0.0; z[5]  =  0.0;
134   x[6]  =  2.0; y[6]  =  1.0; z[6]  =  0.0;
135   x[7]  =  1.0; y[7]  =  1.0; z[7]  =  0.0;
136
137/* Hex #1 */
138   x[8]  =  0.0; y[8]  =  0.0; z[8]  =  0.0;
139   x[9]  = 10.0; y[9]  =  0.0; z[9]  =  0.0;
140   x[10] = 10.0; y[10] =  0.0; z[10] =-10.0;
141   x[11] =  1.0; y[11] =  0.0; z[11] =-10.0;
142   x[12] =  1.0; y[12] = 10.0; z[12] =  0.0;
143   x[13] = 10.0; y[13] = 10.0; z[13] =  0.0;
144   x[14] = 10.0; y[14] = 10.0; z[14] =-10.0;
145   x[15] =  1.0; y[15] = 10.0; z[15] =-10.0;
146
147/* Tetra #1 */
148   x[16] =  0.0; y[16] =  0.0; z[16] =  0.0;
149   x[17] =  1.0; y[17] =  0.0; z[17] =  5.0;
150   x[18] = 10.0; y[18] =  0.0; z[18] =  2.0;
151   x[19] =  7.0; y[19] =  5.0; z[19] =  3.0;
152
153/* Circle #1 */
154   x[20] = 100.0; y[20] = 100.0; z[20] = 0.0;
155
156/* Sphere #1 */
157   x[21] = 50.0; y[21] = 50.0; z[21] = 20.0;
158
159/* Wedge #1 */
160   x[22] =  3.0; y[22] =  0.0; z[22] =  6.0;
161   x[23] =  6.0; y[23] =  0.0; z[23] =  0.0;
162   x[24] =  0.0; y[24] =  0.0; z[24] =  0.0;
163   x[25] =  3.0; y[25] =  2.0; z[25] =  6.0;
164   x[26] =  6.0; y[26] =  2.0; z[26] =  2.0;
165   x[27] =  0.0; y[27] =  2.0; z[27] =  0.0;
166
167   error = ex_put_coord (exoid, x, y, z);
168   printf ("after ex_put_coord, error = %d\n", error);
169
170
171   coord_names[0] = "xcoor";
172   coord_names[1] = "ycoor";
173   coord_names[2] = "zcoor";
174
175   error = ex_put_coord_names (exoid, coord_names);
176   printf ("after ex_put_coord_names, error = %d\n", error);
177
178
179/* write element order map */
180
181   elem_map = (int *) calloc(num_elem, sizeof(int));
182
183   for (i=1; i<=num_elem; i++)
184   {
185      elem_map[i-1] = i;
186   }
187
188   error = ex_put_map (exoid, elem_map);
189   printf ("after ex_put_map, error = %d\n", error);
190
191   free (elem_map);
192
193/* write element numbering map */
194
195   elem_map = (int *) calloc(num_elem, sizeof(int));
196
197   for (i=1; i<=num_elem; i++)
198   {
199      elem_map[i-1] = i*2;
200   }
201
202   error = ex_put_elem_num_map (exoid, elem_map);
203   printf ("after ex_put_elem_num_map, error = %d\n", error);
204
205   free (elem_map);
206
207
208/* write node numbering map */
209
210   node_map = (int *) calloc(num_nodes, sizeof(int));
211
212   for (i=1; i<=num_nodes; i++)
213   {
214      node_map[i-1] = i*3;
215   }
216
217   error = ex_put_node_num_map (exoid, node_map);
218   printf ("after ex_put_node_num_map, error = %d\n", error);
219
220   free (node_map);
221
222
223/* write element block parameters */
224
225   num_elem_in_block[0] = 1; /* element 1: Quad 1 */
226   num_elem_in_block[1] = 2; /* elements 2, 3: Quad 1 & 2 */
227   num_elem_in_block[2] = 1; /* element 4: Hex    */
228   num_elem_in_block[3] = 1; /* element 5: Tetra  */
229   num_elem_in_block[4] = 1; /* element 6: Circle */
230   num_elem_in_block[5] = 1; /* element 7: Sphere */
231   num_elem_in_block[6] = 1; /* element 8: Wedge  */
232
233   num_nodes_per_elem[0] = 4; /* elements in block #1 are 4-node quads  */
234   num_nodes_per_elem[1] = 4; /* elements in block #2 are 4-node quads  */
235   num_nodes_per_elem[2] = 8; /* elements in block #3 are 8-node hexes  */
236   num_nodes_per_elem[3] = 4; /* elements in block #3 are 4-node tetras */
237   num_nodes_per_elem[4] = 1; /* elements in block #4 are 1-node circles */
238   num_nodes_per_elem[5] = 1; /* elements in block #5 are 1-node spheres */
239   num_nodes_per_elem[6] = 6; /* elements in block #6 are 6-node wedges */
240
241   ebids[0] = 10;
242   ebids[1] = 11;
243   ebids[2] = 12;
244   ebids[3] = 13;
245   ebids[4] = 14;
246   ebids[5] = 15;
247   ebids[6] = 16;
248
249   num_attr[0] = 3;
250   num_attr[1] = 3;
251   num_attr[2] = 3;
252   num_attr[3] = 3;
253   num_attr[4] = 3;
254   num_attr[5] = 3;
255   num_attr[6] = 3;
256
257   error = ex_put_elem_block (exoid, ebids[0], "quad", num_elem_in_block[0],
258                              num_nodes_per_elem[0], num_attr[0]);
259   printf ("after ex_put_elem_block, error = %d\n", error);
260
261   error = ex_put_elem_block (exoid, ebids[1], "quad", num_elem_in_block[1],
262                               num_nodes_per_elem[1], num_attr[1]);
263   printf ("after ex_put_elem_block, error = %d\n", error);
264
265   error = ex_put_elem_block (exoid, ebids[2], "hex", num_elem_in_block[2],
266                               num_nodes_per_elem[2], num_attr[2]);
267   printf ("after ex_put_elem_block, error = %d\n", error);
268
269   error = ex_put_elem_block (exoid, ebids[3], "tetra", num_elem_in_block[3],
270                               num_nodes_per_elem[3], num_attr[3]);
271   printf ("after ex_put_elem_block, error = %d\n", error);
272
273   error = ex_put_elem_block (exoid, ebids[4], "circle", num_elem_in_block[4],
274                               num_nodes_per_elem[4], num_attr[4]);
275   printf ("after ex_put_elem_block, error = %d\n", error);
276
277   error = ex_put_elem_block (exoid, ebids[5], "sphere", num_elem_in_block[5],
278                               num_nodes_per_elem[5], num_attr[5]);
279   printf ("after ex_put_elem_block, error = %d\n", error);
280
281   error = ex_put_elem_block (exoid, ebids[6], "wedge", num_elem_in_block[6],
282                               num_nodes_per_elem[6], num_attr[6]);
283   printf ("after ex_put_elem_block, error = %d\n", error);
284
285/* write element block properties */
286
287   prop_names[0] = "MATL";
288   prop_names[1] = "DENSITY";
289   error = ex_put_prop_names(exoid,EX_ELEM_BLOCK,2,prop_names);
290   printf ("after ex_put_prop_names, error = %d\n", error);
291
292   error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[0], "MATL", 10);
293   printf ("after ex_put_prop, error = %d\n", error);
294   error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[1], "MATL", 20);
295   printf ("after ex_put_prop, error = %d\n", error);
296   error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[2], "MATL", 30);
297   printf ("after ex_put_prop, error = %d\n", error);
298   error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[3], "MATL", 40);
299   printf ("after ex_put_prop, error = %d\n", error);
300   error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[4], "MATL", 50);
301   printf ("after ex_put_prop, error = %d\n", error);
302   error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[5], "MATL", 60);
303   printf ("after ex_put_prop, error = %d\n", error);
304   error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[6], "MATL", 70);
305   printf ("after ex_put_prop, error = %d\n", error);
306
307/* write element connectivity */
308
309   connect = (int *) calloc(8, sizeof(int));
310   connect[0] = 1; connect[1] = 2; connect[2] = 3; connect[3] = 4;
311
312   error = ex_put_elem_conn (exoid, ebids[0], connect);
313   printf ("after ex_put_elem_conn, error = %d\n", error);
314
315   connect[0] = 1; connect[1] = 2; connect[2] = 3; connect[3] = 4;
316   connect[4] = 5; connect[5] = 6; connect[6] = 7; connect[7] = 8;
317
318   error = ex_put_elem_conn (exoid, ebids[1], connect);
319   printf ("after ex_put_elem_conn, error = %d\n", error);
320
321   connect[0] = 9; connect[1] = 10; connect[2] = 11; connect[3] = 12;
322   connect[4] = 13; connect[5] = 14; connect[6] = 15; connect[7] = 16;
323
324   error = ex_put_elem_conn (exoid, ebids[2], connect);
325   printf ("after ex_put_elem_conn, error = %d\n", error);
326
327   connect[0] = 17; connect[1] = 18; connect[2] = 19; connect[3] = 20;
328
329   error = ex_put_elem_conn (exoid, ebids[3], connect);
330   printf ("after ex_put_elem_conn, error = %d\n", error);
331
332   connect[0] = 21;
333
334   error = ex_put_elem_conn (exoid, ebids[4], connect);
335   printf ("after ex_put_elem_conn, error = %d\n", error);
336
337   connect[0] = 22;
338
339   error = ex_put_elem_conn (exoid, ebids[5], connect);
340   printf ("after ex_put_elem_conn, error = %d\n", error);
341
342   connect[0] = 23; connect[1] = 24; connect[2] = 25;
343   connect[3] = 26; connect[4] = 27; connect[5] = 28;
344
345   error = ex_put_elem_conn (exoid, ebids[6], connect);
346   printf ("after ex_put_elem_conn, error = %d\n", error);
347
348   free (connect);
349
350
351/* write element block attributes  (3 per block) */
352
353   attrib[0] = 1.0; attrib[1] = 2.0; attrib[2] = 3.0;
354   attrib[3] = 1.11; attrib[4] = 2.11; attrib[5] = 3.11;
355   attrib[6] = 1.12; attrib[7] = 2.12; attrib[8] = 3.12;
356   attrib[9] = 1.2; attrib[10] = 2.2; attrib[11] = 3.2;
357   attrib[12] = 1.3; attrib[13] = 2.3; attrib[14] = 3.3;
358   attrib[15] = 1.4; attrib[16] = 2.4; attrib[17] = 3.4;
359   attrib[18] = 1.5; attrib[19] = 2.5; attrib[20] = 3.5;
360   attrib[21] = 1.6; attrib[22] = 2.6; attrib[23] = 3.6;
361
362   error = ex_put_elem_attr (exoid, ebids[0], &attrib[0]);
363   printf ("after ex_put_elem_attr, error = %d\n", error);
364
365   error = ex_put_elem_attr (exoid, ebids[1], &attrib[3]);
366   printf ("after ex_put_elem_attr, error = %d\n", error);
367
368   error = ex_put_elem_attr (exoid, ebids[2], &attrib[9]);
369   printf ("after ex_put_elem_attr, error = %d\n", error);
370
371   error = ex_put_elem_attr (exoid, ebids[3], &attrib[12]);
372   printf ("after ex_put_elem_attr, error = %d\n", error);
373
374   error = ex_put_elem_attr (exoid, ebids[4], &attrib[15]);
375   printf ("after ex_put_elem_attr, error = %d\n", error);
376
377   error = ex_put_elem_attr (exoid, ebids[5], &attrib[18]);
378   printf ("after ex_put_elem_attr, error = %d\n", error);
379
380   error = ex_put_elem_attr (exoid, ebids[6], &attrib[21]);
381   printf ("after ex_put_elem_attr, error = %d\n", error);
382
383/* write individual node sets */
384
385   /* COMMENTED OUT ...
386
387   error = ex_put_node_set_param (exoid, 20, 5, 5);
388   printf ("after ex_put_node_set_param, error = %d\n", error);
389
390   node_list[0] = 10; node_list[1] = 11; node_list[2] = 12; 
391   node_list[3] = 13; node_list[4] = 14; 
392
393   dist_fact[0] = 1.0; dist_fact[1] = 2.0; dist_fact[2] = 3.0;
394   dist_fact[3] = 4.0; dist_fact[4] = 5.0;
395
396   error = ex_put_node_set (exoid, 20, node_list);
397   printf ("after ex_put_node_set, error = %d\n", error);
398   error = ex_put_node_set_dist_fact (exoid, 20, dist_fact);
399   printf ("after ex_put_node_set_dist_fact, error = %d\n", error);
400
401   error = ex_put_node_set_param (exoid, 21, 3, 3);
402   printf ("after ex_put_node_set_param, error = %d\n", error);
403
404   node_list[0] = 20; node_list[1] = 21; node_list[2] = 22; 
405
406   dist_fact[0] = 1.1; dist_fact[1] = 2.1; dist_fact[2] = 3.1;
407
408   error = ex_put_node_set (exoid, 21, node_list);
409   printf ("after ex_put_node_set, error = %d\n", error);
410   error = ex_put_node_set_dist_fact (exoid, 21, dist_fact);
411   printf ("after ex_put_node_set_dist_fact, error = %d\n", error);
412
413   error = ex_put_prop(exoid, EX_NODE_SET, 20, "FACE", 4);
414   printf ("after ex_put_prop, error = %d\n", error);
415   error = ex_put_prop(exoid, EX_NODE_SET, 21, "FACE", 5);
416   printf ("after ex_put_prop, error = %d\n", error);
417
418   prop_array[0] = 1000;
419   prop_array[1] = 2000;
420
421   error = ex_put_prop_array(exoid, EX_NODE_SET, "VELOCITY", prop_array);
422   printf ("after ex_put_prop_array, error = %d\n", error);
423
424   END COMMENTED OUT SECTION */
425
426/* write concatenated node sets; this produces the same information as
427 * the above code which writes individual node sets
428 */
429
430/* THIS SECTION IS NOT COMMENTED OUT */
431
432   ids[0] = 20; ids[1] = 21;
433
434   num_nodes_per_set[0] = 5;
435   num_nodes_per_set[1] = 3;
436   /* num_nodes_per_set[1] = 0; Uncomment to test NULL node sets */
437
438   node_ind[0] = 0; node_ind[1] = 5;
439
440   node_list[0] = 10; node_list[1] = 11; node_list[2] = 12; 
441   node_list[3] = 13; node_list[4] = 14; 
442   node_list[5] = 20; node_list[6] = 21; node_list[7] = 22;
443
444   num_df_per_set[0] = 5; num_df_per_set[1] = 3;
445
446   df_ind[0] = 0; df_ind[1] = 5;
447
448   dist_fact[0] = 1.0; dist_fact[1] = 2.0; dist_fact[2] = 3.0; 
449   dist_fact[3] = 4.0; dist_fact[4] = 5.0; 
450   dist_fact[5] = 1.1; dist_fact[6] = 2.1; dist_fact[7] = 3.1;
451
452   error = ex_put_concat_node_sets (exoid, ids, num_nodes_per_set,
453                                    num_df_per_set, node_ind,
454                                    df_ind, node_list, dist_fact);
455   printf ("after ex_put_concat_node_sets, error = %d\n", error);
456
457   error = ex_put_prop(exoid, EX_NODE_SET, 20, "FACE", 4);
458   printf ("after ex_put_prop, error = %d\n", error);
459   error = ex_put_prop(exoid, EX_NODE_SET, 21, "FACE", 5);
460   printf ("after ex_put_prop, error = %d\n", error);
461
462   prop_array[0] = 1000;
463   prop_array[1] = 2000;
464
465   error = ex_put_prop_array(exoid, EX_NODE_SET, "VELOCITY", prop_array);
466   printf ("after ex_put_prop_array, error = %d\n", error);
467
468   /* END NOT COMMENTED OUT SECTION */
469
470
471/* write individual side sets */
472
473   /* COMMENTED OUT SECTION ...
474
475   error = ex_put_side_set_param (exoid, 30, 2, 4);
476   printf ("after ex_put_side_set_param, error = %d\n", error);
477
478   elem_list[0] = 1; elem_list[1] = 1;
479
480   node_list[0] = 1; node_list[1] = 2;
481   node_list[2] = 5; node_list[3] = 6;
482
483   side_list[0] = 1; side_list[1] = 1;
484
485   dist_fact[0] = 30.0; dist_fact[1] = 30.1; dist_fact[2] = 30.2;
486   dist_fact[3] = 30.3;
487
488   error = ex_put_side_set (exoid, 30, elem_list, side_list);
489   printf ("after ex_put_side_set, error = %d\n", error);
490
491   error = ex_put_side_set_dist_fact (exoid, 30, dist_fact);
492   printf ("after ex_put_side_set_dist_fact, error = %d\n", error);
493
494
495   error = ex_put_side_set_param (exoid, 31, 2, 4);
496   printf ("after ex_put_side_set_param, error = %d\n", error);
497
498   elem_list[0] = 2; elem_list[1] = 2;
499
500   node_list[0] = 6; node_list[1] = 7;
501   node_list[2] = 7; node_list[3] = 8;
502
503   side_list[0] = 3; side_list[1] = 3;
504
505   dist_fact[0] = 31.0; dist_fact[1] = 31.1; dist_fact[2] = 31.2;
506   dist_fact[3] = 31.3;
507
508   error = ex_put_side_set (exoid, 31, elem_list, side_list);
509   printf ("after ex_put_side_set, error = %d\n", error);
510
511   error = ex_put_side_set_dist_fact (exoid, 31, dist_fact);
512   printf ("after ex_put_side_set_dist_fact, error = %d\n", error);
513
514   error = ex_put_prop(exoid, EX_SIDE_SET, 30, "COLOR", 100);
515   printf ("after ex_put_prop, error = %d\n", error);
516
517   error = ex_put_prop(exoid, EX_SIDE_SET, 31, "COLOR", 101);
518   printf ("after ex_put_prop, error = %d\n", error);
519
520   END COMMENTED OUT SECTION */
521
522/* write concatenated side sets; this produces the same information as
523 * the above code which writes individual side sets
524 */
525
526/* THIS SECTION IS NOT COMMENTED OUT */
527
528   ids[0] = 30;
529   ids[1] = 31;
530   ids[2] = 32;
531   ids[3] = 33;
532   ids[4] = 34;
533   ids[5] = 35;
534
535   /* side set #1  - quad */
536   node_list[0] = 8; node_list[1] = 5;
537   node_list[2] = 6; node_list[3] = 7;
538
539   /* side set #2  - quad/hex, spanning 2 element types  */
540   node_list[4] = 2; node_list[5] = 3;
541   node_list[6] = 7; node_list[7] = 8;
542
543   /* side set #3  - hex */
544   node_list[8] = 9; node_list[9] = 12;
545   node_list[10] = 11; node_list[11] = 10;
546
547
548   node_list[12] = 11; node_list[13] = 12;
549   node_list[14] = 16; node_list[15] = 15;
550 
551   node_list[16] = 16; node_list[17] = 15;
552   node_list[18] = 11; node_list[19] = 12;
553
554   node_list[20] = 10; node_list[21] = 11;
555   node_list[22] = 15; node_list[23] = 14;
556
557   node_list[24] = 13; node_list[25] = 16;
558   node_list[26] = 12; node_list[27] =  9;
559
560   node_list[28] = 14; node_list[29] = 13;
561   node_list[30] =  9; node_list[31] = 10;
562
563   node_list[32] = 16; node_list[33] = 13;
564   node_list[34] = 14; node_list[35] = 15;
565
566   /* side set #4  - tetras */
567   node_list[36] = 17; node_list[37] = 18;
568   node_list[38] = 20;
569
570   node_list[39] = 18; node_list[40] = 19;
571   node_list[41] = 20;
572
573   node_list[42] = 20; node_list[43] = 19;
574   node_list[44] = 17;
575
576   node_list[45] = 19; node_list[46] = 18;
577   node_list[47] = 17;
578
579   /* side set #5  - circle and sphere */
580   node_list[48] = 21; 
581   node_list[49] = 22;
582
583   /* side set #6  - wedges */
584   node_list[50] = 27; node_list[51] = 26;
585   node_list[52] = 23; node_list[53] = 24;
586
587   node_list[54] = 28; node_list[55] = 27;
588   node_list[56] = 24; node_list[57] = 25;
589
590   node_list[58] = 28; node_list[59] = 25;
591   node_list[60] = 23; node_list[61] = 26;
592
593   node_list[62] = 25; node_list[63] = 24;
594   node_list[64] = 23;
595
596   node_list[65] = 26; node_list[66] = 27;
597   node_list[67] = 28;
598
599   node_ind[0] = 0;
600   node_ind[1] = 4;
601   node_ind[2] = 8;
602   node_ind[3] = 36;
603   node_ind[4] = 47;
604   node_ind[5] = 49;
605
606   num_elem_per_set[0] = 2; /* two sides uses 2 elements */
607   num_elem_per_set[1] = 2;
608   num_elem_per_set[2] = 7;
609   num_elem_per_set[3] = 4;
610   num_elem_per_set[4] = 2;
611   num_elem_per_set[5] = 5;
612   /* num_elem_per_set[5] = 0; Uncomment to test NULL side sets */
613
614   num_nodes_per_set[0] = 4;
615   num_nodes_per_set[1] = 4;
616   num_nodes_per_set[2] = 28;
617   num_nodes_per_set[3] = 12;
618   num_nodes_per_set[4] =  2;
619   num_nodes_per_set[5] = 18;
620
621   elem_ind[0] = 0;
622   elem_ind[1] = 2;
623   elem_ind[2] = 4;
624   elem_ind[3] = 11;
625   elem_ind[4] = 15;
626   elem_ind[5] = 17;
627
628   elem_list[0] = 3; elem_list[1] = 3; /* side set 1: Quad #2 */
629   elem_list[2] = 1; elem_list[3] = 3; /* side set 2: Quad #1 & #2 */
630   elem_list[4] = 4; elem_list[5] = 4; /* side set 3: Hex */
631   elem_list[6] = 4; elem_list[7] = 4;
632   elem_list[8] = 4; elem_list[9] = 4;
633   elem_list[10] = 4; 
634   elem_list[11] = 5; elem_list[12] = 5; /* side set 4: Tetra */
635   elem_list[13] = 5; elem_list[14] = 5; 
636   elem_list[15] = 6; elem_list[16] = 7; /* side set 5: Circle & Sphere */
637   elem_list[17] = 8; elem_list[18] = 8; /* side set 6: Wedge  */
638   elem_list[19] = 8; elem_list[20] = 8; 
639   elem_list[21] = 8;
640
641#if 0
642   /* side set 0 */
643     side_list[0]= 4; side_list[1]= 2;
644   /* side set 1 */
645     side_list[2]= 2; side_list[3]= 3; 
646   /* side set 2 */
647     side_list[4]= 5; side_list[5]= 3;
648   side_list[6]= 3; side_list[7]= 2;
649   side_list[8]= 4; side_list[9]= 1;
650   side_list[10]= 6;
651   /* side set 3 */
652     side_list[11]= 1; side_list[12]= 2;
653   side_list[13]= 3; side_list[14]= 4; 
654   /* side set 4 */
655     side_list[15] = 1; side_list[16] = 1;
656   /*   side set 5  */
657     side_list[17]= 1; side_list[18]= 2;
658   side_list[19]= 3; side_list[20]= 4;
659   side_list[21]= 5;
660#endif
661
662   error = ex_cvt_nodes_to_sides(exoid,
663                         num_elem_per_set,
664                         num_nodes_per_set,
665                         elem_ind,
666                         node_ind,
667                         elem_list,
668                         node_list,
669                         side_list);
670   printf ("after ex_cvt_nodes_to_sides, error = %d\n", error);
671
672#if 0
673   for (i=0;i<num_side_sets;i++)
674   {
675     printf("side set %d\n",i);
676     for (j=0;j<num_elem_per_set[i];j++)
677       printf("  side_list[%d]: %d\n",j,side_list[j+elem_ind[i]]);
678   }
679#endif
680
681   num_df_per_set[0] = 4;
682   num_df_per_set[1] = 4;
683   num_df_per_set[2] = 0;
684   num_df_per_set[3] = 0;
685   num_df_per_set[4] = 0;
686   num_df_per_set[5] = 0;
687
688   df_ind[0] = 0;
689   df_ind[1] = 4;
690
691   /* side set #1 df */
692   dist_fact[0] = 30.0; dist_fact[1] = 30.1;
693   dist_fact[2] = 30.2; dist_fact[3] = 30.3;
694
695   /* side set #2 df */
696   dist_fact[4] = 31.0; dist_fact[5] = 31.1;
697   dist_fact[6] = 31.2; dist_fact[7] = 31.3;
698
699   error = ex_put_concat_side_sets (exoid, ids, num_elem_per_set,
700                                    num_df_per_set, elem_ind, df_ind,
701                                    elem_list, side_list, dist_fact);
702   printf ("after ex_put_concat_side_sets, error = %d\n", error);
703
704   error = ex_put_prop(exoid, EX_SIDE_SET, 30, "COLOR", 100);
705   printf ("after ex_put_prop, error = %d\n", error);
706
707   error = ex_put_prop(exoid, EX_SIDE_SET, 31, "COLOR", 101);
708   printf ("after ex_put_prop, error = %d\n", error);
709
710   /* END COMMENTED OUT SECTION */
711
712/* write QA records */
713
714   num_qa_rec = 2;
715
716
717   qa_record[0][0] = "TESTWT1";
718   qa_record[0][1] = "testwt1";
719   qa_record[0][2] = "03/16/94";
720   qa_record[0][3] = "15:41:33";
721   qa_record[1][0] = "FASTQ";
722   qa_record[1][1] = "fastq";
723   qa_record[1][2] = "07/07/93";
724   qa_record[1][3] = "16:41:33";
725
726   error = ex_put_qa (exoid, num_qa_rec, qa_record);
727   printf ("after ex_put_qa, error = %d\n", error);
728
729
730/* write information records */
731
732   num_info = 3;
733
734
735   info[0] = "This is the first information record.";
736   info[1] = "This is the second information record.";
737   info[2] = "This is the third information record.";
738
739   error = ex_put_info (exoid, num_info, info);
740   printf ("after ex_put_info, error = %d\n", error);
741
742
743
744/* write results variables parameters and names */
745
746   num_glo_vars = 1;
747
748   var_names[0] = "glo vars";
749
750   error = ex_put_var_param (exoid, "g", num_glo_vars);
751   printf ("after ex_put_var_param, error = %d\n", error);
752   error = ex_put_var_name(exoid, "g", 1, var_names[0]);
753   printf ("after ex_put_var_name, error = %d\n", error);
754
755
756   num_nod_vars = 2;
757
758   var_names[0] = "nod_var0";
759   var_names[1] = "nod_var1";
760
761   error = ex_put_var_param (exoid, "n", num_nod_vars);
762   printf ("after ex_put_var_param, error = %d\n", error);
763   error = ex_put_var_names (exoid, "n", num_nod_vars, var_names);
764   printf ("after ex_put_var_names, error = %d\n", error);
765
766   num_ele_vars = 3;
767
768   var_names[0] = "ele_var0";
769   var_names[1] = "ele_var1";
770   var_names[2] = "ele_var2";
771
772   error = ex_put_var_param (exoid, "e", num_ele_vars);
773   printf ("after ex_put_var_param, error = %d\n", error);
774   error = ex_put_var_names (exoid, "e", num_ele_vars, var_names);
775   printf ("after ex_put_var_names, error = %d\n", error);
776
777
778/* write element variable truth table */
779
780   truth_tab = (int *) calloc ((num_elem_blk*num_ele_vars), sizeof(int));
781
782   k = 0;
783   for (i=0; i<num_elem_blk; i++)
784   {
785      for (j=0; j<num_ele_vars; j++)
786      {
787         truth_tab[k] = k+1;
788         k++;
789      }
790   }
791
792   truth_tab[6] = 0;
793
794   /* commented out to test ex_get_elem_var_tab in testrd1
795   error = ex_put_elem_var_tab (exoid, num_elem_blk, num_ele_vars, truth_tab);
796   printf ("after ex_put_elem_var_tab, error = %d\n", error); */
797
798   free (truth_tab);
799
800
801/* for each time step, write the analysis results;
802 * the code below fills the arrays glob_var_vals, 
803 * nodal_var_vals, and elem_var_vals with values for debugging purposes;
804 * obviously the analysis code will populate these arrays
805 */
806
807   whole_time_step = 1;
808   num_time_steps = 10;
809
810   glob_var_vals = (float *) calloc (num_glo_vars, CPU_word_size);
811   nodal_var_vals = (float *) calloc (num_nodes, CPU_word_size);
812   elem_var_vals = (float *) calloc (4, CPU_word_size);
813
814   for (i=0; i<num_time_steps; i++)
815   {
816     time_value = (float)(i+1)/100.;
817
818/* write time value */
819
820     error = ex_put_time (exoid, whole_time_step, &time_value);
821     printf ("after ex_put_time, error = %d\n", error);
822
823/* write global variables */
824
825     for (j=0; j<num_glo_vars; j++)
826     {
827       glob_var_vals[j] = (float)(j+2) * time_value;
828     }
829
830     error = ex_put_glob_vars (exoid, whole_time_step, num_glo_vars, 
831                               glob_var_vals);
832     printf ("after ex_put_glob_vars, error = %d\n", error);
833
834/* write nodal variables */
835
836     for (k=1; k<=num_nod_vars; k++)
837     {
838       for (j=0; j<num_nodes; j++)
839       {
840         nodal_var_vals[j] = (float)k + ((float)(j+1) * time_value);
841       }
842
843       error = ex_put_nodal_var (exoid, whole_time_step, k, num_nodes,
844                                 nodal_var_vals);
845       printf ("after ex_put_nodal_var, error = %d\n", error);
846     }
847
848/* write element variables */
849
850     for (k=1; k<=num_ele_vars; k++)
851     {
852       for (j=0; j<num_elem_blk; j++)
853       {
854         for (m=0; m<num_elem_in_block[j]; m++)
855         {
856           elem_var_vals[m] = (float)(k+1) + (float)(j+2) + 
857                              ((float)(m+1)*time_value);
858           /* printf("elem_var_vals[%d]: %f\n",m,elem_var_vals[m]); */
859         }
860         if (k == 1 && j == 2)
861           continue; /* skip element block 3, variable 1 */
862         else
863         {
864           error = ex_put_elem_var (exoid, whole_time_step, k, ebids[j],
865                                  num_elem_in_block[j], elem_var_vals);
866           printf ("after ex_put_elem_var, error = %d\n", error);
867         }
868       }
869     }
870
871     whole_time_step++;
872
873/* update the data file; this should be done at the end of every time step
874 * to ensure that no data is lost if the analysis dies
875 */
876     error = ex_update (exoid);
877     printf ("after ex_update, error = %d\n", error);
878   }
879   free(glob_var_vals);
880   free(nodal_var_vals);
881   free(elem_var_vals);
882
883
884/* close the EXODUS files
885 */
886   error = ex_close (exoid);
887   printf ("after ex_close, error = %d\n", error);
888   return 0;
889}