BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / applications / test / ensightFoamReader / udr_checker-90.c
blobc3197bf8e9a810a3f02d7c120b8512db96336671
1 /*----------------------------------
2 * User Defined Reader - checker
3 *----------------------------------*/
5 /********************************************************************
7 * ****************************************
8 * Copyright 2004 Computational Engineering International, Inc.
9 * All Rights Reserved.
11 * Restricted Rights Legend
13 * Use, duplication, or disclosure of this
14 * software and its documentation by the
15 * Government is subject to restrictions as
16 * set forth in subdivision [(b)(3)(ii)] of
17 * the Rights in Technical Data and Computer
18 * Software clause at 52.227-7013.
19 *******************************************************************/
21 /*----------------------------------------------------------------------
22 * MAJOR ROUTINES ACCESS: (VERSION 2.00) Gold_Userd API
24 * Get the name of the reader
25 * ==========================
26 * USERD_get_name_of_reader
27 * USERD_get_extra_gui_numbers (optional)
28 * USERD_get_extra_gui_defaults (optional)
30 * Get the reader version
31 * ======================
32 * USERD_get_reader_version
34 * Set the filenames, gather timeset and time info
35 * ===============================================
36 * USERD_set_extra_gui_data (optional)
37 * USERD_set_server_number
38 * USERD_set_filenames
39 * USERD_get_number_of_timesets
40 * USERD_get_geom_timeset_number
42 * for each timeset:
43 * USERD_get_timeset_description
44 * USERD_get_num_of_time_steps
45 * USERD_get_sol_times
47 * USERD_set_time_set_and_step
50 * Gather variable and time info
51 * =============================
52 * USERD_get_number_of_variables
53 * USERD_get_gold_variable_info
56 * Get initial part building info
57 * ==============================
58 * USERD_set_time_set_and_step
59 * USERD_get_changing_geometry_status
60 * USERD_get_node_label_status
61 * USERD_get_element_label_status
62 * USERD_get_number_of_files_in_dataset
63 * USERD_get_dataset_query_file_info
64 * USERD_get_descrip_lines (geometry)
65 * USERD_get_number_of_model_parts
66 * USERD_get_gold_part_build_info
67 * USERD_get_ghosts_in_model_flag
68 * USERD_get_maxsize_info
69 * USERD_get_ghosts_in_block_flag (if any ghost cells in model)
70 * USERD_get_model_extents **OR**
71 * USERD_get_part_coords **AND/OR**
72 * USERD_get_block_coords_by_component
76 * Part Builder
77 * ============
79 * both unstructured and structured
80 * --------------------------------
81 * USERD_set_time_set_and_step
83 * if unstructured
84 * ---------------
85 * USERD_get_part_element_ids_by_type
86 * USERD_get_part_elements_by_type
88 * if any nsided elements:
89 * USERD_get_nsided_conn
91 * if any nfaced elements:
92 * USERD_get_nfaced_nodes_per_face
93 * USERD_get_nfaced_conn
95 * USERD_get_part_coords
96 * USERD_get_part_node_ids
98 * else if structured
99 * ------------------
100 * USERD_get_block_iblanking
101 * USERD_get_block_coords_by_component
102 * USERD_get_block_ghost_flags
103 * USERD_get_part_node_ids (If node ids given)
104 * USERD_get_part_element_ids_by_type (If element ids given)
106 * both again
107 * ----------
108 * USERD_get_border_availability (If border representation
109 * USERD_get_border_elements_by_type is selected)
111 * USERD_stop_part_building
114 * Changing geometry
115 * =================
117 * changing coords only
118 * --------------------
119 * USERD_set_time_set_and_step
120 * USERD_get_descrip_lines
121 * USERD_get_part_coords
122 * USERD_get_block_coords_by_component
124 * changing connectivity
125 * ---------------------
126 * USERD_set_time_set_and_step
127 * USERD_get_descrip_lines
128 * USERD_get_number_of_model_parts
129 * USERD_get_gold_part_build_info
130 * USERD_get_ghosts_in_model_flag
131 * USERD_get_ghosts_in_block_flag (If any ghost cells in model)
132 * USERD_get_model_extents **OR**
133 * USERD_get_part_coords **AND/OR**
134 * USERD_get_block_coords_by_component
135 * USERD_get_part_element_ids_by_type
136 * USERD_get_part_elements_by_type
137 * USERD_get_part_coords
138 * USERD_get_part_node_ids
139 * USERD_get_block_iblanking
140 * USERD_get_block_coords_by_component
141 * USERD_get_block_ghost_flags (If ghost cells in part)
142 * USERD_get_part_node_ids (If node ids given)
143 * USERD_get_part_element_ids_by_type (If element ids given)
145 * USERD_get_border_availability (If border representation
146 * USERD_get_border_elements_by_type is selected)
149 * Loading Variables
150 * ==================
152 * constants
153 * ---------
154 * USERD_set_time_set_and_step
155 * USERD_get_constant_val
157 * scalars/vectors/tensors
158 * -----------------------
159 * USERD_get_description_lines
160 * USERD_set_time_set_and_step
161 * USERD_get_var_by_component
164 * Node or Element queries over time
165 * =================================
166 * USERD_get_var_value_at_specific
169 * At 2.03, added:
170 * ---------------
172 * Materials
173 * =========
174 * USERD_get_number_of_material_sets
175 * USERD_get_matf_set_info
177 * If any material sets in the model (calls once per material set)
178 * USERD_get_number_of_materials
179 * USERD_get_matf_var_info
181 * For each element type of each part containing material ids
182 * USERD_size_matf_data
183 * USERD_load_matf_data
186 * At 2.04, added:
187 * ---------------
188 * USERD_get_uns_failed_params - Sets params used in element failure
191 *----------------------------------------------------------------------*/
193 /*----------------------------------------------------------------------
194 * MAJOR ROUTINES ACCESS: (Version 1.00) original API
196 * Get the name of the reader
197 * ==========================
198 * USERD_get_name_of_reader
199 * USERD_get_extra_gui_numbers (optional -extra_gui on command line)
200 * USERD_get_extra_gui_defaults (optional -extra_gui on command line)
202 * Set the filenames
203 * =================
204 * USERD_set_extra_gui_data (optional -extra_gui on command line)
205 * USERD_set_filenames
206 * USERD_get_number_of_time_steps
207 * USERD_get_solution_times
208 * USERD_set_time_step
211 * Gather variable and time info
212 * =============================
213 * USERD_get_number_of_variables
214 * USERD_get_variable_info
217 * Get initial part building info
218 * ==============================
219 * USERD_set_time_step
220 * USERD_get_changing_geometry_status
221 * USERD_get_node_label_status
222 * USERD_get_element_label_status
223 * USERD_get_number_of_files_in_dataset
224 * USERD_get_dataset_query_file_info
225 * USERD_get_description_lines (geometry)
226 * USERD_get_number_of_model_parts
227 * USERD_get_part_build_info
228 * USERD_get_number_global_nodes
229 * USERD_get_global_coords
230 * USERD_get_block_coords_by_component
232 * Failure Info
233 * ============
234 * USERD_get_uns_failed_params
237 * Part Builder
238 * ============
239 * USERD_set_time_step
240 * USERD_get_global_coords
241 * USERD_get_global_node_ids
242 * USERD_get_element_connectivities_for_part
243 * USERD_get_element_ids_for_part
244 * USERD_get_block_iblanking
245 * USERD_get_block_coords_by_component
247 * USERD_stop_part_building
250 * Changing geometry
251 * =================
253 * changing coords only
254 * --------------------
255 * USERD_set_time_step
256 * USERD_get_global_coords
257 * USERD_get_block_coords_by_component
259 * changing connectivity
260 * ---------------------
261 * USERD_set_time_step
262 * USERD_get_number_of_model_parts
263 * USERD_get_part_build_info
264 * USERD_get_number_global_nodes
265 * USERD_get_global_coords
266 * USERD_get_global_node_ids
267 * USERD_get_element_connectivities_for_part
268 * USERD_get_element_ids_for_part
269 * USERD_get_block_iblanking
270 * USERD_get_block_coords_by_component
272 * Loading Variables
273 * =================
275 * constants:
276 * ----------
277 * USERD_set_time_step
278 * USERD_get_constant_value
280 * scalars:
281 * --------
282 * USERD_get_description_lines
283 * USERD_set_time_step
284 * USERD_get_scalar_values
285 * USERD_get_block_scalar_values
287 * vectors:
288 * --------
289 * USERD_get_description_lines
290 * USERD_set_time_step
291 * USERD_get_vector_values
292 * USERD_get_block_vector_values_by_component
295 * Node or Element queries over time
296 * =================================
297 * USERD_get_variable_value_at_specific
299 *----------------------------------------------------------------------*/
300 #include <stdio.h>
301 #include <stdlib.h>
302 #ifndef WIN32
303 #include <unistd.h>
304 #endif
305 #include <string.h>
306 #include <ctype.h>
307 #include <sys/types.h>
308 #ifndef CONVEX
309 #include <malloc.h>
310 #endif
311 #include <math.h>
313 #include "global_extern.h"
315 /* -----------------------------------------------
316 * If you wish to test out various optional routines
317 * you must uncomment the proper #define below
319 * #define _EGS is for extra_gui routines
320 * #define _VES is for var_extract_gui routines
321 *---------------------------------------------------*/
322 /* #define _EGS */
323 /* #define _VES */
326 #if (defined USERD_API_209)
327 #define GT_USERD_API_100
328 #define GT_USERD_API_200
329 #define GT_USERD_API_201
330 #define GT_USERD_API_202
331 #define GT_USERD_API_203
332 #define GT_USERD_API_204
333 #define GT_USERD_API_205
334 #define GT_USERD_API_206
335 #define GT_USERD_API_207
336 #define GT_USERD_API_208
338 #elif (defined USERD_API_208)
339 #define GT_USERD_API_100
340 #define GT_USERD_API_200
341 #define GT_USERD_API_201
342 #define GT_USERD_API_202
343 #define GT_USERD_API_203
344 #define GT_USERD_API_204
345 #define GT_USERD_API_205
346 #define GT_USERD_API_206
347 #define GT_USERD_API_207
349 #elif (defined USERD_API_207)
350 #define GT_USERD_API_100
351 #define GT_USERD_API_200
352 #define GT_USERD_API_201
353 #define GT_USERD_API_202
354 #define GT_USERD_API_203
355 #define GT_USERD_API_204
356 #define GT_USERD_API_205
357 #define GT_USERD_API_206
359 #elif (defined USERD_API_206)
360 #define GT_USERD_API_100
361 #define GT_USERD_API_200
362 #define GT_USERD_API_201
363 #define GT_USERD_API_202
364 #define GT_USERD_API_203
365 #define GT_USERD_API_204
366 #define GT_USERD_API_205
368 #elif (defined USERD_API_205)
369 #define GT_USERD_API_100
370 #define GT_USERD_API_200
371 #define GT_USERD_API_201
372 #define GT_USERD_API_202
373 #define GT_USERD_API_203
374 #define GT_USERD_API_204
376 #elif (defined USERD_API_204)
377 #define GT_USERD_API_100
378 #define GT_USERD_API_200
379 #define GT_USERD_API_201
380 #define GT_USERD_API_202
381 #define GT_USERD_API_203
383 #elif (defined USERD_API_203)
384 #define GT_USERD_API_100
385 #define GT_USERD_API_200
386 #define GT_USERD_API_201
387 #define GT_USERD_API_202
389 #elif (defined USERD_API_202)
390 #define GT_USERD_API_100
391 #define GT_USERD_API_200
392 #define GT_USERD_API_201
394 #elif (defined USERD_API_201)
395 #define GT_USERD_API_100
396 #define GT_USERD_API_200
398 #elif (defined USERD_API_200)
399 #define GT_USERD_API_100
400 #endif
403 #define EOS '\0'
405 typedef struct {
406 int id; /* part_id */
407 char desc[Z_BUFL]; /* description given in the file */
408 int type; /* Z_UNSTRUCTURED, Z_STRUCTURED, Z_IBLANKED */
409 int ne[Z_MAXTYPE]; /* Number of elements per type (Z_UNSTRUCTURED) */
410 /* or ne[0] = I dimension (Z_STRUCTURED) */
411 /* ne[1] = J dimension */
412 /* ne[2] = K dimension */
413 int nn; /* Num of unstructured nodes (All_Local only) */
414 int ghosts; /* TRUE if ghost cells, FALSE otherwise */
415 }BUILDINFO;
417 typedef struct {
418 char description[Z_BUFL]; /* description */
419 char filename[Z_BUFL]; /* real filename */
420 char ifilename[Z_BUFL]; /* imaginary filename */
421 int type;
422 int classify;
423 int complex;
424 float freq;
425 int contran;
426 int timeset;
427 }VARINFO;
430 typedef struct {
431 char name[12]; /* Z_POINT, Z_G_POINT, Z_BAR02, ... */
432 int con_len; /* Number of nodes per element */
433 }EINFO;
436 /* Global variables
437 *-----------------*/
438 int Geom_status;
439 int Node_labels;
440 int Element_labels;
441 int Ghosts_in_model;
442 int Num_parts;
443 int Num_vars;
444 int Num_materials_sets;
445 BUILDINFO *Pbuild;
446 VARINFO *Varinfo;
447 char Version_number[Z_MAX_USERD_NAME];
448 int Num_time_sets;
449 int Num_time_steps;
451 /* ------------------
452 * Extra GUI stuff
453 * ------------------ */
454 int Num_toggles = 0;
455 int Num_pulldowns = 0;
456 int Num_fields = 0;
457 char **Toggle_title;
458 int *Toggle_default_status;
459 char **Pulldown_title;
460 int *Pulldown_number_in_list;
461 int *Pulldown_default_selection;
462 char ***Pulldown_item_strings;
463 char **Field_title;
464 char **Field_user_string;
465 int *Toggle_choice; /* user choice */
466 int *Pulldown_choice; /* user choice */
468 /* ------------------
469 * Var Extract stuff
470 * ------------------ */
471 int Num_ve_toggles = 0;
472 int Num_ve_pulldowns = 0;
473 int Num_ve_fields = 0;
474 char **Toggle_ve_title;
475 int *Toggle_ve_default_status;
476 char **Pulldown_ve_title;
477 int *Pulldown_ve_number_in_list;
478 int *Pulldown_ve_default_selection;
479 char ***Pulldown_ve_item_strings;
480 char **Field_ve_title;
481 char **Field_ve_user_string;
482 int *Toggle_ve_choice; /* user choice */
483 int *Pulldown_ve_choice; /* user choice */
485 /* ---------------------------
486 * Failed elements (API 2.04)
487 * --------------------------- */
488 int Any_uns_failed_model_elems = FALSE;
490 /* ---------------------------
491 * Rigidbody (API 2.05)
492 * --------------------------- */
493 int Any_Rigid_Body_Present = FALSE;
495 /* ---------------------------
496 * Structured Reader Cinching (API 2.06)
497 * --------------------------- */
498 int Doing_Structured_Cinching = FALSE;
502 #if (defined USERD_API_100 || defined USERD_API_200)
503 EINFO Elem_info[Z_MAXTYPE] = {"Z_POINT",1,
504 "Z_BAR02",2,
505 "Z_BAR03",3,
506 "Z_TRI03",3,
507 "Z_TRI06",6,
508 "Z_QUA04",4,
509 "Z_QUA08",8,
510 "Z_TET04",4,
511 "Z_TET10",10,
512 "Z_PYR05",5,
513 "Z_PYR13",13,
514 "Z_PEN06",6,
515 "Z_PEN15",15,
516 "Z_HEX08",8,
517 "Z_HEX20",20};
518 #elif defined USERD_API_201
519 EINFO Elem_info[Z_MAXTYPE] = {"Z_POINT", 1,
520 "Z_G_POINT",1,
521 "Z_BAR02", 2,
522 "Z_G_BAR02",2,
523 "Z_BAR03", 3,
524 "Z_G_BAR03",3,
525 "Z_TRI03", 3,
526 "Z_G_TRI03",3,
527 "Z_TRI06", 6,
528 "Z_G_TRI06",6,
529 "Z_QUA04", 4,
530 "Z_G_QUA04",4,
531 "Z_QUA08", 8,
532 "Z_G_QUA08",8,
533 "Z_TET04", 4,
534 "Z_G_TET04",4,
535 "Z_TET10", 10,
536 "Z_G_TET10",10,
537 "Z_PYR05", 5,
538 "Z_G_PYR05",5,
539 "Z_PYR13", 13,
540 "Z_G_PYR13",13,
541 "Z_PEN06", 6,
542 "Z_G_PEN06",6,
543 "Z_PEN15", 15,
544 "Z_G_PEN15",15,
545 "Z_HEX08", 8,
546 "Z_G_HEX08",8,
547 "Z_HEX20", 20,
548 "Z_G_HEX20",20};
549 #else
550 EINFO Elem_info[Z_MAXTYPE] = {"Z_POINT", 1,
551 "Z_G_POINT",1,
552 "Z_BAR02", 2,
553 "Z_G_BAR02",2,
554 "Z_BAR03", 3,
555 "Z_G_BAR03",3,
556 "Z_TRI03", 3,
557 "Z_G_TRI03",3,
558 "Z_TRI06", 6,
559 "Z_G_TRI06",6,
560 "Z_QUA04", 4,
561 "Z_G_QUA04",4,
562 "Z_QUA08", 8,
563 "Z_G_QUA08",8,
564 "Z_TET04", 4,
565 "Z_G_TET04",4,
566 "Z_TET10", 10,
567 "Z_G_TET10",10,
568 "Z_PYR05", 5,
569 "Z_G_PYR05",5,
570 "Z_PYR13", 13,
571 "Z_G_PYR13",13,
572 "Z_PEN06", 6,
573 "Z_G_PEN06",6,
574 "Z_PEN15", 15,
575 "Z_G_PEN15",15,
576 "Z_HEX08", 8,
577 "Z_G_HEX08",8,
578 "Z_HEX20", 20,
579 "Z_G_HEX20",20,
580 "Z_NSIDED", 1, /* Not yet implemented */
581 "Z_G_NSIDED",1, /* Not yet implemented */
582 "Z_NFACED", 1, /* Not yet implemented */
583 "Z_G_NFACED",1}; /* Not yet implemented */
584 #endif
587 /* Prototypes
588 *-----------*/
589 static int load_fail_defaults(void);
590 static int prelim_info(int *two_fields,
591 int *any_extra_gui,
592 int *any_var_extract);
593 static int get_input(int set_server_number,
594 int use_playfile,
595 char playfile[Z_MAXFILENP],
596 int two_fields,
597 int any_extra_gui,
598 int any_var_extract,
599 int *swapbytes);
600 static int time_info( void );
601 static int part_build_info(int geom_time_step);
602 static int variable_info( void );
604 #if (defined GT_USERD_API_100)
605 static int gold_part_builder(int geom_time_step);
606 static int gold_var_loader(int var_time_step);
607 #else
608 static int part_builder(int geom_time_step);
609 static int var_loader(int var_time_step);
610 #endif
612 #if (defined GT_USERD_API_100)
613 static int materials_info( void );
614 static int gold_materials_loader(int geom_time_step);
615 #endif
617 static int entity_querys(int var_time_step);
618 static int exercise_bkup( void );
619 static void usage( void );
622 /*=============
623 * Main Routine
624 *=============*/
625 #ifdef WIN32
626 int main(int argc, char *argv[])
627 #else
628 int main(int argc, char *argv[])
629 #endif
631 /* Command line option variables
632 *------------------------------*/
633 int set_server_number = FALSE;
634 int use_playfile = FALSE;
635 char playfile[Z_MAXFILENP];
636 FILE *fplay;
637 int geom_time_step = 0;
638 int var_time_step = 0;
640 /* Other local variables
641 *----------------------*/
642 int i, j;
643 int err;
644 int two_fields;
645 int any_extra_gui = FALSE;
646 int any_var_extract = FALSE;
647 int swapbytes;
648 int indx;
650 /*----------------------------
651 * Command argument processing
652 *----------------------------*/
653 fprintf(stderr,"\n");
654 fprintf(stderr,"\n");
655 fprintf(stderr,"********************************************\n");
656 fprintf(stderr,"* EnSight User Defined Reader Debug Tool *\n");
657 fprintf(stderr,"********************************************\n");
658 fprintf(stderr,"\n");
660 indx = 1;
661 while(indx < argc) {
663 if(!strcmp("-h",argv[indx])) {
664 usage();
666 else if(!strcmp("-help",argv[indx])) {
667 usage();
670 /* if you want to test the server number routines
672 * Use:
673 * > checker -server_number
675 * You will then be prompted for the current and total
676 * number of servers
677 *-----------------------------------------------*/
678 else if(!strcmp("-server_number",argv[indx])) {
679 set_server_number = TRUE;
682 /* if you want to use a "playfile" instead of being prompted
683 * for the data loader information
685 * Use:
686 * > checker -p <playfile>
688 * This playfile should have 3 [or 4] lines:
689 * line 1: the path
690 * line 2: filename_1
691 * line 3: [filename_2] (if two_fields is TRUE)
692 * line 4: 0 or 1, for swapytes (0 is FALSE, 1 is TRUE)
694 * example (two_fields is FALSE, so only 3 lines):
696 * /usr/scratch/stealth/bjn/dat/sp_gold/binary
697 * simple.case
700 *------------------------------------------------------*/
701 else if(!strcmp("-p",argv[indx])) {
702 indx++;
703 if((indx < argc) && (argv[indx][0] != '-')) {
704 use_playfile = TRUE;
705 memset(playfile,EOS,Z_MAXFILENP);
706 strcpy(playfile,argv[indx]);
708 else {
709 usage();
713 /* if you want to specify the geometry timestep to test (default is step 0)
715 * Use:
716 * > checker -gts #
718 * Where # is the step number (zero based)
719 *-------------------------------------------------------------------------*/
720 else if(!strcmp("-gts",argv[indx])) {
721 indx++;
722 if((indx < argc) && (argv[indx][0] != '-')) {
723 geom_time_step = atoi(argv[indx]);
725 else {
726 usage();
730 /* if you want to specify the variable timestep to test (default is step 0)
731 * (will use this step for the appropriate timeset of each variable)
733 * Use:
734 * > checker -vts #
736 * Where # is the step number (zero based)
737 *-------------------------------------------------------------------------*/
738 else if(!strcmp("-vts",argv[indx])) {
739 indx++;
740 if((indx < argc) && (argv[indx][0] != '-')) {
741 var_time_step = atoi(argv[indx]);
743 else {
744 usage();
747 else {
748 usage();
751 indx++;
755 /*-------------------------------------------------------------
757 * Now start exercising EnSight
759 *--------------------------------------------------------------*/
761 /*-----------------
762 * Preliminary info
763 *-----------------*/
764 err = prelim_info(&two_fields,&any_extra_gui,&any_var_extract);
765 if(err == Z_ERR) {
766 fprintf(stderr,"Stopping because of error in prelim_info\n");
767 exit(1);
771 /*------------------
772 * User input needed
773 *------------------*/
774 err = get_input(set_server_number,
775 use_playfile,
776 playfile,
777 two_fields,
778 any_extra_gui,
779 any_var_extract,
780 &swapbytes);
781 if(err == Z_ERR) {
782 fprintf(stderr,"Stopping because of error in get_input\n");
783 exit(1);
787 /*----------
788 * Time info
789 *----------*/
790 err = time_info();
791 if(err == Z_ERR) {
792 fprintf(stderr,"Stopping because of error in time_info\n");
793 exit(1);
797 /*----------------
798 * Part build info
799 *----------------*/
800 err = part_build_info(geom_time_step);
801 if(err == Z_ERR) {
802 fprintf(stderr,"Stopping because of error in part_build_info\n");
803 exit(1);
807 /*------------------
808 * Get Variable Info
809 *------------------*/
810 err = variable_info();
811 if(err == Z_ERR) {
812 fprintf(stderr,"Stopping because of error in variable_info\n");
813 exit(1);
817 #if (defined GT_USERD_API_202)
818 /*-------------------
819 * Get Materials Info
820 *-------------------*/
821 err = materials_info();
822 if(err == Z_ERR) {
823 fprintf(stderr,"Stopping because of error in materials_info\n");
824 exit(1);
826 #endif
828 #if (defined GT_USERD_API_203)
829 if (Z_ERR == load_fail_defaults()) {
830 fprintf(stderr,"Stopping due to error in failed element flag routine\n");
831 exit(1);
833 #endif
835 #if (defined GT_USERD_API_204)
837 /*-----------------------------------------------
838 * Mel needs to do these species routines yet!!!
839 *----------------------------------------------*/
840 /* USERD_get_matsp_info
841 USERD_get_number_of_species */
844 /* See if any rigid body in model
845 *-------------------------------*/
846 fprintf(stderr,"\n------------- rigid body existence -------------\n");
847 if(USERD_rigidbody_existence() == Z_OK) {
848 fprintf(stderr," Rigid Body values exist in the model\n");
849 Any_Rigid_Body_Present = TRUE;
851 else {
852 fprintf(stderr," N0 Rigid Body values exist in the model\n");
855 #endif
858 #if (defined GT_USERD_API_205)
860 /* See if doing structured cinching
861 *---------------------------------*/
862 fprintf(stderr,"\n------------- structured reader cinching existence -------------\n");
863 if(USERD_get_structured_reader_cinching() == Z_OK) {
864 fprintf(stderr," Doing structured reader cinching\n");
865 fprintf(stderr," for each of the i,j,k directions,\n");
866 fprintf(stderr," will send in min and max unchanged, but\n");
867 fprintf(stderr," will send in stride as 2\n");
868 Doing_Structured_Cinching = TRUE;
870 else {
871 fprintf(stderr," NOT doing structured reader cinching\n");
873 #endif
875 #if (defined GT_USERD_API_206)
877 /* Probably won't do either of these - trivial
878 *--------------------------------------------*/
879 /* USERD_prefer_auto_distribute <optional> */
880 /* USERD_set_filename_button_labels <optional> */
881 #endif
884 #if (defined GT_USERD_API_207)
886 /* If we choose to do these, Bruce should implement them
887 *------------------------------------------------------*/
888 /* All the _buffer routines! <optional> */
890 /* If we choose to do these, Bill should implement them
891 *-----------------------------------------------------*/
892 /* USERD_get_num_xy_queries <optional>
893 USERD_get_xy_query_data <optional>
894 USERD_get_xy_query_info <optional> */
896 #endif
898 #if (defined GT_USERD_API_208)
900 /* If we choose to do these, Bruce should implement them
901 *------------------------------------------------------*/
902 /* VGLYPH routines <optional> */
903 #endif
905 /*------------------------
906 * Act like building parts
907 *------------------------*/
908 if(Num_parts > 0) {
910 #if (defined GT_USERD_API_100)
911 err = gold_part_builder(geom_time_step);
912 #else
913 err = part_builder(geom_time_step);
914 #endif
915 if(err == Z_ERR) {
916 fprintf(stderr,"Stopping because of error in part_builder\n");
917 exit(1);
919 else {
920 USERD_stop_part_building();
925 /*---------------------------
926 * Act like loading variables
927 *---------------------------*/
928 if(Num_vars > 0) {
930 #if (defined GT_USERD_API_100)
931 err = gold_var_loader(var_time_step);
932 #else
933 err = var_loader(var_time_step);
934 #endif
935 if(err == Z_ERR) {
936 fprintf(stderr,"Stopping because of error in var_loader\n");
937 exit(1);
941 #if (defined GT_USERD_API_202)
942 /*---------------------------
943 * Act like loading materials
944 *---------------------------*/
945 if(Num_materials_sets > 0) {
946 err = gold_materials_loader(geom_time_step);
947 if(err == Z_ERR) {
948 fprintf(stderr,"Stopping because of error in materials_loader\n");
949 exit(1);
952 #endif
956 /*----------------------------------------------------
957 * See if can do node and/or element queries over time
958 *----------------------------------------------------*/
959 if(Num_parts > 0 &&
960 Num_vars > 0) {
961 err = entity_querys(var_time_step);
962 if(err == Z_ERR) {
963 fprintf(stderr,"Stopping because of error in entity_querys\n");
964 exit(1);
968 /*----------------------------------------
969 * Call the bkup file once in save mode,
970 * then again in restore mode - so someone
971 * could debug if desired
972 *----------------------------------------*/
973 err = exercise_bkup();
974 if(err == Z_ERR) {
975 fprintf(stderr,"Stopping due to error in saving and/or restoring archive\n");
976 exit(1);
979 /*-------------
980 * Exit Routine
981 *-------------*/
982 fprintf(stderr,"\n----------------- exiting ---------------\n");
984 #if (defined GT_USERD_API_100)
985 USERD_exit_routine();
986 #endif
988 fprintf(stderr,"\n\n");
990 return(0);
993 /*--------------
994 * Usage routine
995 *--------------*/
996 static void
997 usage( void )
999 fprintf(stderr,"------------------------------------------------------------\n");
1000 fprintf(stderr,"USAGE: checker [-p pfile] [-server_number] [-gts #] [-vts #]\n");
1001 fprintf(stderr,"------------------------------------------------------------\n");
1002 fprintf(stderr," -h, -help Prints out this USAGE text.\n");
1003 fprintf(stderr," -gts # Specify the geometry time step to use.)\n");
1004 fprintf(stderr," -p pfile Plays the checker playfile (pfile).\n");
1005 fprintf(stderr," -server_number Cause servers numbers to be prompted for.\n");
1006 fprintf(stderr," -vts # Specify the variable time step to use.)\n");
1007 fprintf(stderr,"\n");
1008 exit(1);
1014 /*------------
1015 * prelim_info
1016 *------------*/
1017 static int
1018 prelim_info(int *two_fields, int *any_extra_gui, int *any_var_extract)
1020 int err;
1021 char reader_name[Z_MAX_USERD_NAME];
1022 char release_number[Z_MAX_USERD_NAME];
1023 char description[Z_MAXFILENP];
1024 int i,j;
1026 *any_extra_gui = FALSE;
1027 *any_var_extract = FALSE;
1029 /* Get the reader name
1030 *--------------------*/
1031 err = USERD_get_name_of_reader(reader_name,two_fields);
1032 if(err == Z_OK) {
1033 fprintf(stderr," Name of reader: %s\n",reader_name);
1034 if(*two_fields==1) {
1035 fprintf(stderr," two_fields: TRUE\n");
1037 else if(*two_fields==0){
1038 fprintf(stderr," two_fields: FALSE\n");
1040 else if(*two_fields < 0) {
1041 fprintf(stderr," two_fields: -1 (optional string) \n");
1044 else {
1045 fprintf(stderr,"Error: Could not get name of reader\n");
1046 return(Z_ERR);
1049 /* Get the Extra GUI stuff (optional)
1050 * ---------------------------------------------------------- */
1051 #ifdef _EGS
1053 /* Get the Extra GUI numbers of toggles, pulldowns, & fields
1054 * ---------------------------------------------------------- */
1056 USERD_get_extra_gui_numbers( &Num_toggles,
1057 &Num_pulldowns,
1058 &Num_fields );
1060 if ( Num_toggles > 0 || Num_pulldowns > 0 || Num_fields > 0 ) {
1062 *any_extra_gui = TRUE;
1064 if (Num_toggles>0) {
1065 Toggle_title = (char **) calloc(Num_toggles,sizeof(char*));
1066 if (Toggle_title == (char **)NULL) return(Z_ERR);
1067 for (i=0; i<Num_toggles; i++) {
1068 Toggle_title[i] = (char *) calloc(Z_LEN_GUI_TITLE_STR,sizeof(char));
1069 if ( Toggle_title[i] == (char *)NULL ) return(Z_ERR);
1071 Toggle_default_status = (int *) calloc(Num_toggles,sizeof(int));
1072 Toggle_choice = (int *) calloc(Num_toggles,sizeof(int));
1075 if (Num_pulldowns > 0) {
1076 Pulldown_title = (char **) calloc( Num_pulldowns , sizeof(char*) );
1077 if (Pulldown_title == (char **)NULL) return(Z_ERR);
1079 Pulldown_item_strings = (char ***) calloc( Num_pulldowns , sizeof(char**) );
1080 if (Pulldown_item_strings == (char ***)NULL) return(Z_ERR);
1082 for (i=0; i<Num_pulldowns; i++) {
1083 Pulldown_title[i] = (char *) calloc( Z_LEN_GUI_TITLE_STR , sizeof(char) );
1084 if ( Pulldown_title[i] == (char *)NULL ) return(Z_ERR);
1086 Pulldown_item_strings[i] = (char **) calloc( Z_MAX_NUM_GUI_PULL_ITEMS , sizeof(char *) );
1087 if (Pulldown_item_strings[i] == (char **)NULL) return(Z_ERR);
1089 for(j = 0; j < Z_MAX_NUM_GUI_PULL_ITEMS; j++) {
1090 Pulldown_item_strings[i][j] = (char *) calloc( Z_LEN_GUI_PULL_STR , sizeof(char) );
1091 if ( Pulldown_item_strings[i][j] == (char *)NULL ) return(Z_ERR);
1094 Pulldown_number_in_list = (int *) calloc(Num_pulldowns,sizeof(int));
1095 Pulldown_default_selection = (int *) calloc(Num_pulldowns,sizeof(int));
1096 Pulldown_choice = (int *) calloc(Num_pulldowns,sizeof(int));
1099 if (Num_fields > 0) {
1100 Field_title = (char **) calloc(Num_fields,sizeof(char*));
1101 Field_user_string = (char **) calloc(Num_fields,sizeof(char*));
1102 if (Field_title == (char **) NULL) return(Z_ERR);
1103 for (i=0; i<Num_fields; i++) {
1104 Field_title[i] = (char *) calloc(Z_LEN_GUI_TITLE_STR,sizeof(char));
1105 if ( Field_title[i] == (char *)NULL) return(Z_ERR);
1106 Field_user_string[i] = (char *) calloc(Z_LEN_GUI_FIELD_STR,sizeof(char));
1107 if ( Field_user_string[i] == (char *)NULL) return(Z_ERR);
1112 err = USERD_get_extra_gui_defaults(
1113 Toggle_title, /* [num_toggles][Z_LEN_GUI_TITLE_STR] */
1114 Toggle_default_status, /* [num_toggles] */
1115 Pulldown_title, /* [num_pulldowns][Z_LEN_GUI_TITLE_STR] */
1116 Pulldown_number_in_list, /* [num_pulldowns] */
1117 Pulldown_default_selection, /* [num_pulldowns] */
1118 Pulldown_item_strings, /* [num_pulldowns][Z_MAX_NUM_GUI_PULL_ITEMS][Z_LEN_GUI_PULL_STR] */
1119 Field_title, /* [num_fields][Z_LEN_GUI_TITLE_STR] */
1120 Field_user_string /* [num_fields][Z_LEN_GUI_FIELD_STR] */
1122 if (Z_ERR == err) return(Z_ERR);
1124 fprintf(stderr,"\n**********************************************\n");
1125 fprintf(stderr,"**** Extra GUI Information ***\n");
1126 fprintf(stderr,"**********************************************\n\n");
1128 fprintf(stderr,"\nTOGGLE INFO: %d active toggles\n",Num_toggles);
1129 for (i=0; i<Num_toggles; i++) {
1130 fprintf(stderr,"Toggle Title %d : %s\n",i,Toggle_title[i]);
1131 fprintf(stderr,"Default status = %d \n",Toggle_default_status[i]);
1134 fprintf(stderr,"\nPULLDOWN INFO: %d active pulldowns\n",Num_pulldowns);
1135 for (i=0; i<Num_pulldowns; i++) {
1136 fprintf(stderr,"Pulldown Title %d : %s\n", i , Pulldown_title[i] );
1137 for (j=0; j<Z_MAX_NUM_GUI_PULL_ITEMS; j++) {
1138 fprintf(stderr,"Pulldown_item %d : %s\n",j,Pulldown_item_strings[i][j]);
1139 if (strlen(Pulldown_item_strings[i][j]) == 0) {
1140 Pulldown_number_in_list[i] = j;
1141 break;
1144 fprintf(stderr,"Number of items in list: %d\n",Pulldown_number_in_list[i]);
1145 fprintf(stderr,"Default selection: %d\n\n",Pulldown_default_selection[i]);
1147 fprintf(stderr,"\n");
1149 fprintf(stderr,"\nFIELDINFO: %d active fields\n",Num_fields);
1150 for (i=0; i<Num_fields; i++) {
1151 fprintf(stderr,"Field Title %d : %s\n",i,Field_title[i]);
1152 fprintf(stderr,"Field string %d: %s\n",i,Field_user_string[i]);
1154 fprintf(stderr,"\n\n\n");
1156 #endif
1159 /* Get the var_extract stuff (optional)
1160 * ---------------------------------------------------------- */
1161 #ifdef _VES
1163 /* Get the var_extract numbers of toggles, pulldowns, & fields
1164 * ---------------------------------------------------------- */
1165 USERD_get_var_extract_gui_numbers(&Num_ve_toggles,
1166 &Num_ve_pulldowns,
1167 &Num_ve_fields );
1168 if ( Num_ve_toggles > 0 || Num_ve_pulldowns > 0 || Num_ve_fields > 0 ) {
1170 *any_var_extract = TRUE;
1172 if (Num_ve_toggles > 0) {
1173 Toggle_ve_title = (char **) calloc(Num_ve_toggles,sizeof(char*));
1174 if (Toggle_ve_title == (char **)NULL) return(Z_ERR);
1175 for (i=0; i<Num_ve_toggles; i++) {
1176 Toggle_ve_title[i] = (char *) calloc(Z_LEN_GUI_TITLE_STR,sizeof(char));
1177 if ( Toggle_ve_title[i] == (char *)NULL ) return(Z_ERR);
1179 Toggle_ve_default_status = (int *) calloc(Num_ve_toggles,sizeof(int));
1180 Toggle_ve_choice = (int *) calloc(Num_ve_toggles,sizeof(int));
1183 if (Num_ve_pulldowns > 0) {
1184 Pulldown_ve_title = (char **) calloc( Num_ve_pulldowns , sizeof(char*) );
1185 if (Pulldown_ve_title == (char **)NULL) return(Z_ERR);
1187 Pulldown_ve_item_strings = (char ***) calloc( Num_ve_pulldowns , sizeof(char**) );
1188 if (Pulldown_ve_item_strings == (char ***)NULL) return(Z_ERR);
1190 for (i=0; i<Num_ve_pulldowns; i++) {
1191 Pulldown_ve_title[i] = (char *) calloc( Z_LEN_GUI_TITLE_STR , sizeof(char) );
1192 if ( Pulldown_ve_title[i] == (char *)NULL ) return(Z_ERR);
1194 Pulldown_ve_item_strings[i] = (char **)calloc(Z_MAX_NUM_GUI_PULL_ITEMS, sizeof(char *));
1195 if (Pulldown_ve_item_strings[i] == (char **)NULL) return(Z_ERR);
1197 for(j = 0; j < Z_MAX_NUM_GUI_PULL_ITEMS; j++) {
1198 Pulldown_ve_item_strings[i][j] = (char *) calloc( Z_LEN_GUI_PULL_STR , sizeof(char) );
1199 if ( Pulldown_ve_item_strings[i][j] == (char *)NULL ) return(Z_ERR);
1202 Pulldown_ve_number_in_list = (int *) calloc(Num_ve_pulldowns,sizeof(int));
1203 Pulldown_ve_default_selection = (int *) calloc(Num_ve_pulldowns,sizeof(int));
1204 Pulldown_ve_choice = (int *) calloc(Num_ve_pulldowns,sizeof(int));
1207 if (Num_ve_fields > 0) {
1208 Field_ve_title = (char **) calloc(Num_ve_fields,sizeof(char*));
1209 Field_ve_user_string = (char **) calloc(Num_ve_fields,sizeof(char*));
1210 if (Field_ve_title == (char **) NULL) return(Z_ERR);
1211 for (i=0; i<Num_ve_fields; i++) {
1212 Field_ve_title[i] = (char *) calloc(Z_LEN_GUI_TITLE_STR,sizeof(char));
1213 if ( Field_ve_title[i] == (char *)NULL) return(Z_ERR);
1214 Field_ve_user_string[i] = (char *) calloc(Z_LEN_GUI_FIELD_STR,sizeof(char));
1215 if ( Field_ve_user_string[i] == (char *)NULL) return(Z_ERR);
1220 err = USERD_get_var_extract_gui_defaults(
1221 Toggle_ve_title, /* [num_ve_toggles][Z_LEN_GUI_TITLE_STR] */
1222 Toggle_ve_default_status, /* [num_ve_toggles] */
1223 Pulldown_ve_title, /* [num_ve_pulldowns][Z_LEN_GUI_TITLE_STR] */
1224 Pulldown_ve_number_in_list, /* [num_ve_pulldowns] */
1225 Pulldown_ve_default_selection, /* [num_ve_pulldowns] */
1226 Pulldown_ve_item_strings, /* [num_ve_pulldowns][Z_MAX_NUM_GUI_PULL_ITEMS][Z_LEN_GUI_PULL_STR] */
1227 Field_ve_title, /* [num_ve_fields][Z_LEN_GUI_TITLE_STR] */
1228 Field_ve_user_string /* [num_ve_fields][Z_LEN_GUI_FIELD_STR] */
1230 if (Z_ERR == err) return(Z_ERR);
1232 fprintf(stderr,"\n**********************************************\n");
1233 fprintf(stderr,"**** Var Extract Information ***\n");
1234 fprintf(stderr,"**********************************************\n\n");
1236 fprintf(stderr,"\nTOGGLE INFO: %d active toggles\n",Num_ve_toggles);
1237 for (i=0; i<Num_ve_toggles; i++) {
1238 fprintf(stderr,"Toggle Title %d : %s\n",i,Toggle_ve_title[i]);
1239 fprintf(stderr,"Default status = %d \n",Toggle_ve_default_status[i]);
1242 fprintf(stderr,"\nPULLDOWN INFO: %d active pulldowns\n",Num_ve_pulldowns);
1243 for (i=0; i<Num_ve_pulldowns; i++) {
1244 fprintf(stderr,"Pulldown Title %d : %s\n", i , Pulldown_ve_title[i] );
1245 for (j=0; j<Z_MAX_NUM_GUI_PULL_ITEMS; j++) {
1246 fprintf(stderr,"Pulldown_item %d : %s\n",j,Pulldown_ve_item_strings[i][j]);
1247 if (strlen(Pulldown_ve_item_strings[i][j]) == 0) {
1248 Pulldown_ve_number_in_list[i] = j;
1249 break;
1252 fprintf(stderr,"Number of items in list: %d\n",Pulldown_ve_number_in_list[i]);
1253 fprintf(stderr,"Default selection: %d\n\n",Pulldown_ve_default_selection[i]);
1255 fprintf(stderr,"\n");
1257 fprintf(stderr,"\nFIELDINFO: %d active fields\n",Num_ve_fields);
1258 for (i=0; i<Num_ve_fields; i++) {
1259 fprintf(stderr,"Field Title %d : %s\n",i,Field_ve_title[i]);
1260 fprintf(stderr,"Field string %d: %s\n",i,Field_ve_user_string[i]);
1262 fprintf(stderr,"\n\n\n");
1264 #endif
1267 #if (defined GT_USERD_API_100)
1269 /* Get the reader api used
1270 *------------------------*/
1271 err = USERD_get_reader_version(Version_number);
1272 if(err == Z_OK) {
1273 fprintf(stderr," API version: %s\n",Version_number);
1275 else {
1276 fprintf(stderr,"Error: Could not get reader api version\n");
1277 return(Z_ERR);
1280 /* Get the reader release
1281 *-----------------------*/
1282 err = USERD_get_reader_release(release_number);
1283 if(err == Z_OK) {
1284 fprintf(stderr," Release: %s\n",release_number);
1286 else {
1287 fprintf(stderr,"Error: Could not get reader release\n");
1288 return(Z_ERR);
1290 #else
1291 fprintf(stderr," API version: 1.00\n");
1292 #endif
1295 #if 0
1296 /* Get the reader description
1297 *---------------------------*/
1298 err = USERD_get_reader_descrip(description);
1299 if(err == Z_OK) {
1300 fprintf(stderr," Description:\n\n");
1301 fprintf(stderr,"%s\n\n",description);
1303 else {
1304 fprintf(stderr,"Error: Could not get reader description\n");
1305 return(Z_ERR);
1307 #else
1308 fprintf(stderr," Note: Not currently calling USERD_get_reader_descrip\n");
1309 fprintf(stderr," because it is optional.\n");
1310 #endif
1312 return(Z_OK);
1316 /*----------
1317 * get_input
1318 *----------*/
1319 static int
1320 get_input(int set_server_number,
1321 int use_playfile,
1322 char playfile[Z_MAXFILENP],
1323 int two_fields,
1324 int any_extra_gui,
1325 int any_var_extract,
1326 int *swapbytes)
1328 FILE *fplay;
1330 int i, j;
1331 int err;
1332 int tot_servers;
1333 int cur_server;
1334 char the_path[Z_MAXFILENP];
1335 char file1[Z_MAXFILENP];
1336 char file2[Z_MAXFILENP];
1337 char filename_1[Z_MAXFILENP];
1338 char filename_2[Z_MAXFILENP];
1341 fprintf(stderr,"\n-------------- get_input ----------------\n");
1343 /*-----------------------------------------------------
1344 * Prompt for the two input values, as the client would
1345 * And set this info for the reader
1346 *-----------------------------------------------------*/
1348 #if (defined GT_USERD_API_100)
1350 /* Set the server number - if command line option to do so
1351 *--------------------------------------------------------*/
1352 if(set_server_number) {
1353 fprintf(stderr," Enter total number of servers: ");
1354 scanf("%d",&tot_servers);
1356 fprintf(stderr," Enter current server number: ");
1357 scanf("%d",&cur_server);
1359 fprintf(stderr," Setting %d of %d for server number\n",cur_server,tot_servers);
1360 USERD_set_server_number(cur_server,tot_servers);
1362 #endif
1364 /* Set the filenames
1365 *------------------*/
1366 memset(the_path,EOS,Z_MAXFILENP);
1367 memset(file1,EOS,Z_MAXFILENP);
1368 memset(file2,EOS,Z_MAXFILENP);
1369 memset(filename_1,EOS,Z_MAXFILENP);
1370 memset(filename_2,EOS,Z_MAXFILENP);
1373 if(!use_playfile) {
1374 fprintf(stderr," Enter the path: ");
1375 scanf("%s",the_path);
1378 fprintf(stderr," Enter filename_1: ");
1379 scanf("%s",file1);
1381 if(two_fields == TRUE) {
1382 fprintf(stderr," Enter filename_2: ");
1383 scanf("%s",file2);
1386 fprintf(stderr," Enter Swapbytes (0 if FALSE, 1 if TRUE): ");
1387 scanf("%d",swapbytes);
1389 if (TRUE == any_extra_gui ) {
1390 fprintf(stderr,"\n**********************************************\n");
1391 fprintf(stderr,"**** Extra GUI INPUT ***\n");
1392 fprintf(stderr,"**********************************************\n\n");
1394 fprintf(stderr, "\n TOGGLE INPUT \n");
1395 for (i=0; i<Num_toggles; i++) {
1396 fprintf(stderr, " Enter Toggle Value for '%s' (1=toggle on, 0=toggle off)\n",Toggle_title[i]);
1397 scanf("%d",&Toggle_choice[i]);
1399 fprintf(stderr, "\n PULLDOWN INPUT \n");
1400 for (i=0; i<Num_pulldowns; i++) {
1401 fprintf(stderr, "\n PULLDOWN # %d \n",i);
1402 for (j = 0; j<Pulldown_number_in_list[i]; j++) {
1403 fprintf(stderr, " %d %s\n",j,Pulldown_item_strings[i][j]);
1405 fprintf(stderr, " Enter Pulldown Value for '%s' (0 to %d)\n",Pulldown_title[i],Pulldown_number_in_list[i]-1);
1406 scanf("%d",&Pulldown_choice[i]);
1408 fprintf(stderr, "\n FIELD INPUT \n");
1409 for (i=0; i<Num_fields; i++) {
1410 fprintf(stderr, "Enter string for field %d '%s'\n",i,Field_title[i]);
1411 scanf("%s",Field_user_string[i]);
1414 } /* end if there is any extra gui stuff */
1416 if (TRUE == any_var_extract ) {
1417 fprintf(stderr,"\n**********************************************\n");
1418 fprintf(stderr,"**** Var extract INPUT ***\n");
1419 fprintf(stderr,"**********************************************\n\n");
1421 fprintf(stderr, "\n TOGGLE INPUT \n");
1422 for (i=0; i<Num_ve_toggles; i++) {
1423 fprintf(stderr, " Enter Toggle Value for '%s' (1=toggle on, 0=toggle off)\n",Toggle_ve_title[i]);
1424 scanf("%d",&Toggle_ve_choice[i]);
1426 fprintf(stderr, "\n PULLDOWN INPUT \n");
1427 for (i=0; i<Num_ve_pulldowns; i++) {
1428 fprintf(stderr, "\n PULLDOWN # %d \n",i);
1429 for (j = 0; j<Pulldown_ve_number_in_list[i]; j++) {
1430 fprintf(stderr, " %d %s\n",j,Pulldown_ve_item_strings[i][j]);
1432 fprintf(stderr, " Enter Pulldown Value for '%s' (0 to %d)\n",Pulldown_ve_title[i],Pulldown_ve_number_in_list[i]-1);
1433 scanf("%d",&Pulldown_ve_choice[i]);
1435 fprintf(stderr, "\n FIELD INPUT \n");
1436 for (i=0; i<Num_ve_fields; i++) {
1437 fprintf(stderr, "Enter string for field %d '%s'\n",i,Field_ve_title[i]);
1438 scanf("%s",Field_ve_user_string[i]);
1441 } /* end if there is any var_extract stuff */
1443 } /* end if not using playfile */
1444 else {
1445 fplay = fopen(playfile,"rb");
1446 if(fplay == (FILE *)NULL) {
1447 fprintf(stderr,"Error: Opening the playfile %s\n",playfile);
1448 return(Z_ERR);
1450 else {
1451 fscanf(fplay,"%s",the_path);
1452 fscanf(fplay,"%s",file1);
1453 if(two_fields == TRUE) {
1454 fscanf(fplay,"%s",file2);
1456 fscanf(fplay,"%d",swapbytes);
1458 /* ---------------------
1459 * Extra GUI stuff
1460 * --------------------- */
1461 if (TRUE == any_extra_gui) {
1463 for (i=0; i<Num_toggles; i++) {
1464 fscanf(fplay,"%d",&Toggle_choice[i]);
1467 for (i=0; i<Num_pulldowns; i++) {
1468 fscanf(fplay,"%d",&Pulldown_choice[i]);
1471 for (i=0; i<Num_fields; i++) {
1472 fscanf(fplay,"%s",Field_user_string[i]);
1476 /* ---------------------
1477 * var_sxtract stuff
1478 * --------------------- */
1479 if (TRUE == any_var_extract) {
1481 for (i=0; i<Num_ve_toggles; i++) {
1482 fscanf(fplay,"%d",&Toggle_ve_choice[i]);
1485 for (i=0; i<Num_ve_pulldowns; i++) {
1486 fscanf(fplay,"%d",&Pulldown_ve_choice[i]);
1489 for (i=0; i<Num_ve_fields; i++) {
1490 fscanf(fplay,"%s",Field_ve_user_string[i]);
1494 fclose(fplay);
1498 #ifdef _EGS
1499 /* -------------------------------------------
1500 * set the user choices here and run the code
1501 * ------------------------------------------- */
1503 /* set your choices here
1504 Toggle_choice[0..Num_toggles]
1505 Pulldown_choice[0..Num_pulldowns]
1506 Field_user_string[Num_fields][0..Numfields]
1507 amd then send your choices into this routine */
1509 USERD_set_extra_gui_data(Toggle_choice, /* [num_toggle] */
1510 Pulldown_choice, /* [num_pulldown] */
1511 Field_user_string ); /* [num_fields][Z_LEN_GUI_FIELD_STR] */
1513 for (i=0; i<Num_toggles; i++) {
1514 fprintf(stderr,"Toggle Title %d : %s\n",i,Toggle_title[i]);
1515 fprintf(stderr,"User selection = %d \n",Toggle_choice[i]);
1517 fprintf(stderr,"\n\n");
1519 for (i=0; i<Num_pulldowns; i++) {
1520 fprintf(stderr,"Pulldown Title %d : %s\n", i , Pulldown_title[i] );
1521 fprintf(stderr,"Pulldown selection is # %d : %s\n",
1522 Pulldown_choice[i],Pulldown_item_strings[i][Pulldown_choice[i]]);
1525 for (i=0; i<Num_fields; i++) {
1526 fprintf(stderr,"Field Title %d : %s\n",i,Field_title[i]);
1527 fprintf(stderr,"Field string %d: %s\n",i,Field_user_string[i]);
1530 #endif
1532 #ifdef _VES
1533 /* -------------------------------------------
1534 * set the user choices here and run the code
1535 * ------------------------------------------- */
1537 /* set your choices here
1538 Toggle_ve_choice[0..Num_ve_toggles]
1539 Pulldown_ve_choice[0..Num_ve_pulldowns]
1540 Field_ve_user_string[Num_ve_fields][0..Numfields]
1541 amd then send your choices into this routine */
1543 USERD_set_var_extract_gui_data(Toggle_ve_choice, /* [num_ve_toggle] */
1544 Pulldown_ve_choice, /* [num_ve_pulldown] */
1545 Field_ve_user_string); /*[num_ve_fields][Z_LEN_GUI_FIELD_STR] */
1547 for (i=0; i<Num_ve_toggles; i++) {
1548 fprintf(stderr,"Toggle Title %d : %s\n",i,Toggle_ve_title[i]);
1549 fprintf(stderr,"User selection = %d \n",Toggle_ve_choice[i]);
1551 fprintf(stderr,"\n\n");
1553 for (i=0; i<Num_ve_pulldowns; i++) {
1554 fprintf(stderr,"Pulldown Title %d : %s\n", i , Pulldown_ve_title[i] );
1555 fprintf(stderr,"Pulldown selection is # %d : %s\n",
1556 Pulldown_ve_choice[i],Pulldown_ve_item_strings[i][Pulldown_ve_choice[i]]);
1559 for (i=0; i<Num_ve_fields; i++) {
1560 fprintf(stderr,"Field Title %d : %s\n",i,Field_ve_title[i]);
1561 fprintf(stderr,"Field string %d: %s\n",i,Field_ve_user_string[i]);
1563 #endif
1566 if(strncmp(file1,"/",1)) {
1567 strcpy(filename_1,the_path);
1568 strcat(filename_1,"/");
1569 strcat(filename_1,file1);
1571 if(two_fields == TRUE) {
1572 if(strncmp(file2,"/",1)) {
1573 strcpy(filename_2,the_path);
1574 strcat(filename_2,"/");
1575 strcat(filename_2,file2);
1578 if(*swapbytes == 0) {
1579 *swapbytes = FALSE;
1581 else {
1582 *swapbytes = TRUE;
1585 /* Feedback
1586 *---------*/
1587 fprintf(stderr," path: %s\n",the_path);
1588 fprintf(stderr," filename_1: %s\n",filename_1);
1589 fprintf(stderr," filename_2: %s\n",filename_2);
1590 if(*swapbytes) {
1591 fprintf(stderr," Swapbytes: TRUE\n");
1593 else {
1594 fprintf(stderr," Swapbytes: FALSE\n");
1597 err = USERD_set_filenames(filename_1,filename_2,the_path,*swapbytes);
1598 if(err == Z_ERR) {
1599 fprintf(stderr,"Error: Trouble setting the filenames\n");
1600 return(Z_ERR);
1603 return(Z_OK);
1607 /*----------
1608 * time_info
1609 *----------*/
1610 static int
1611 time_info( void )
1613 int i;
1614 int err;
1615 int geom_time_set;
1616 int ts;
1617 float *sol_times;
1618 char ts_desc[Z_BUFL];
1620 fprintf(stderr,"\n-------------- time_info ----------------\n");
1622 #if (defined GT_USERD_API_100)
1624 /* Get the number of timesets
1625 *---------------------------*/
1626 Num_time_sets = USERD_get_number_of_timesets();
1627 fprintf(stderr," number of timesets: %d\n",Num_time_sets);
1628 if(Num_time_sets == 0) {
1629 fprintf(stderr," So, static geometry and variables\n");
1630 return(Z_OK);
1633 /* Get the timeset used for the geometry
1634 *--------------------------------------*/
1635 geom_time_set = USERD_get_geom_timeset_number();
1637 fprintf(stderr," geom timeset number: %d\n",geom_time_set);
1638 if(geom_time_set < 1 && Num_time_sets > 0) {
1639 fprintf(stderr,"Error: timeset numbers must be 1 or greater\n");
1640 fprintf(stderr," (unless Num_time_sets is zero also)\n");
1644 /* For each timeset
1645 *-----------------*/
1646 for(ts=1; ts<=Num_time_sets; ++ts) {
1648 fprintf(stderr," Timeset %d:\n",ts);
1650 /* Get the timeset descriptions
1651 *-----------------------------*/
1652 err = USERD_get_timeset_description(ts,ts_desc);
1653 if(err == Z_ERR) {
1654 fprintf(stderr,"Error: getting timeset description\n");
1655 return(Z_ERR);
1657 else {
1658 fprintf(stderr," description: %s\n",ts_desc);
1661 /* Get the number of time steps
1662 *-----------------------------*/
1663 Num_time_steps = USERD_get_num_of_time_steps(ts);
1664 fprintf(stderr," number of time steps: %d\n",Num_time_steps);
1665 if(Num_time_steps < 1) {
1666 fprintf(stderr," Error: Number of time steps returned: %d\n",Num_time_steps);
1667 fprintf(stderr," (Must be >0 to be okay)\n");
1668 return(Z_ERR);
1672 /* Get the solution times
1673 *-----------------------*/
1674 if(Num_time_steps > 0) {
1675 sol_times = (float *) calloc(Num_time_steps,sizeof(float));
1676 if(sol_times == (float *)NULL) {
1677 fprintf(stderr,"Error: allocating for solution times\n");
1678 return(Z_ERR);
1680 else {
1681 err = USERD_get_sol_times(ts,sol_times);
1682 if(err == Z_ERR) {
1683 fprintf(stderr,"Error: getting solution times\n");
1684 return(Z_ERR);
1686 else {
1687 for(i=0; i<Num_time_steps; ++i) {
1688 fprintf(stderr," At step %d, time = %f\n",i,sol_times[i]);
1692 free(sol_times);
1696 #else
1699 /* Get the number of time steps
1700 *-----------------------------*/
1701 Num_time_steps = USERD_get_number_of_time_steps();
1702 fprintf(stderr," Nnumber of time steps: %d\n",Num_time_steps);
1703 if(Num_time_steps < 1) {
1704 fprintf(stderr," Error: Number of time steps returned: %d\n",Num_time_steps);
1705 fprintf(stderr," (Must be >0 to be okay)\n");
1706 return(Z_ERR);
1710 /* Get the solution times
1711 *-----------------------*/
1712 if(Num_time_steps > 0) {
1713 sol_times = (float *) calloc(Num_time_steps,sizeof(float));
1714 if(sol_times == (float *)NULL) {
1715 fprintf(stderr,"Error: allocating for solution times\n");
1716 return(Z_ERR);
1718 else {
1719 err = USERD_get_solution_times(sol_times);
1720 if(err == Z_ERR) {
1721 fprintf(stderr,"Error: getting solution times\n");
1722 return(Z_ERR);
1724 else {
1725 for(i=0; i<Num_time_steps; ++i) {
1726 fprintf(stderr," At step %d, time = %f\n",i,sol_times[i]);
1730 free(sol_times);
1733 #endif
1735 return(Z_OK);
1740 /*----------------
1741 * part_build_info
1742 *----------------*/
1743 static int
1744 part_build_info(int geom_time_step)
1746 int i, j;
1747 int fn;
1748 int err;
1749 int num_dataset_files;
1750 int geom_time_set;
1751 Z_QFILES *qfiles;
1752 char line1[Z_BUFL];
1753 char line2[Z_BUFL];
1755 int *part_ids;
1756 int *part_types;
1757 int *number_of_nodes;
1758 int **num_elems;
1759 int **ijk_dimensions;
1760 int **iblanking_options;
1761 char **part_descriptions;
1763 int ghosts_in_block;
1765 int *max_num_nodes;
1766 int **max_num_elems;
1767 int **max_ijk_dimensions;
1768 float extents[6];
1771 fprintf(stderr,"\n------------ part_build_info ------------\n");
1773 #if (defined GT_USERD_API_100)
1775 /* Get the timeset used for the geometry
1776 *--------------------------------------*/
1777 geom_time_set = USERD_get_geom_timeset_number();
1779 /* Get the number of time steps for this timeset
1780 *----------------------------------------------*/
1781 Num_time_steps = USERD_get_num_of_time_steps(geom_time_set);
1782 if(Num_time_steps < 1) {
1783 fprintf(stderr," Error: Number of time steps returned: %d\n",Num_time_steps);
1784 fprintf(stderr," (Must be >0 to be okay)\n");
1785 return(Z_ERR);
1787 if(geom_time_step > (Num_time_steps - 1)) {
1788 geom_time_step = Num_time_steps - 1;
1791 /* Set the timeset and step - to first step
1792 *-----------------------------------------*/
1793 USERD_set_time_set_and_step(geom_time_set,geom_time_step);
1795 #else
1797 /* Set the time step - to first step
1798 *----------------------------------*/
1799 USERD_set_time_step(geom_time_step);
1801 #endif
1803 /* Get the changing geometry status
1804 *---------------------------------*/
1805 Geom_status = USERD_get_changing_geometry_status();
1806 if(Geom_status == Z_STATIC) {
1807 fprintf(stderr," Geom changing status: Z_STATIC\n");
1809 else if(Geom_status == Z_CHANGE_COORDS) {
1810 fprintf(stderr," Geom changing status: Z_CHANGE_COORDS\n");
1812 else if(Geom_status == Z_CHANGE_CONN) {
1813 fprintf(stderr," Geom changing status: Z_CHANGE_CONN\n");
1815 else {
1816 fprintf(stderr," Invalid Geom changing status!!\n");
1820 /* Get the node label status
1821 *--------------------------*/
1822 Node_labels = USERD_get_node_label_status();
1823 if(Node_labels) {
1824 fprintf(stderr," Node labels will be provided\n");
1826 else {
1827 fprintf(stderr," Node labels will NOT be provided\n");
1830 /* Get the element label status
1831 *-----------------------------*/
1832 Element_labels = USERD_get_element_label_status();
1833 if(Element_labels) {
1834 fprintf(stderr," Element labels will be provided\n");
1836 else {
1837 fprintf(stderr," Element labels will NOT be provided\n");
1840 fprintf(stderr,"\n");
1842 /* Get the number of files in the dataset
1843 *---------------------------------------*/
1844 num_dataset_files = USERD_get_number_of_files_in_dataset();
1845 fprintf(stderr," Number of files in dataset: %d\n",num_dataset_files);
1848 /* Get the dataset query file info
1849 *--------------------------------*/
1850 if(num_dataset_files > 0) {
1852 qfiles = (Z_QFILES *) calloc(num_dataset_files,sizeof(Z_QFILES));
1853 if(qfiles == (Z_QFILES *)NULL) {
1854 fprintf(stderr,"Error: allocating for dataset query files\n");
1855 return(Z_ERR);
1857 else {
1859 for(i=0; i<num_dataset_files; ++i) {
1860 qfiles[i].f_desc = (char **) calloc(10,sizeof(char *));
1861 if(qfiles[i].f_desc == (char **)NULL) {
1862 fprintf(stderr,"Error: allocating for dataset query descrip lines\n");
1863 return(Z_ERR);
1865 else {
1866 for(j=0; j<10; ++j) {
1867 qfiles[i].f_desc[j] = (char *) calloc(Z_MAXFILENP,sizeof(char));
1868 if(qfiles[i].f_desc[j] == (char *)NULL) {
1869 fprintf(stderr,"Error: allocating for dataset query descrip lines\n");
1870 return(Z_ERR);
1876 err = USERD_get_dataset_query_file_info(qfiles);
1877 if(err == Z_OK) {
1878 for(fn=0; fn<num_dataset_files; ++fn) {
1879 fprintf(stderr," For dataset file %d:\n",fn);
1881 fprintf(stderr," name: %s\n",qfiles[fn].name);
1882 fprintf(stderr," size: %d\n",qfiles[fn].sizeb);
1883 fprintf(stderr," time: %s\n",qfiles[fn].timemod);
1884 fprintf(stderr," num desc lines: %d\n",qfiles[fn].num_d_lines);
1885 for(i=0; i<qfiles[fn].num_d_lines; ++i) {
1886 fprintf(stderr," desc line %d: %s\n",i,qfiles[fn].f_desc[i]);
1890 else {
1891 fprintf(stderr,"Error: getting dataset query info\n");
1892 return(Z_ERR);
1896 /* Free allocated memory
1897 *----------------------*/
1898 for(i=0; i<num_dataset_files; ++i) {
1899 for(j=0; j<10; ++j) {
1900 free(qfiles[i].f_desc[j]);
1902 free(qfiles[i].f_desc);
1904 free(qfiles);
1907 fprintf(stderr,"\n-----------------------------------------\n");
1909 #if (defined GT_USERD_API_100)
1911 /* Get the geometry description lines
1912 *-----------------------------------*/
1913 err = USERD_get_descrip_lines(Z_GEOM,0,FALSE,line1,line2);
1914 if(err == Z_OK) {
1915 fprintf(stderr," Geom Desc line1: %s\n",line1);
1916 fprintf(stderr," Geom Desc line2: %s\n",line2);
1918 else {
1919 fprintf(stderr,"Error: getting geom description lines\n");
1920 return(Z_ERR);
1923 #else
1925 /* Get the geometry description lines
1926 *-----------------------------------*/
1927 err = USERD_get_description_lines(Z_GEOM,0,line1,line2);
1928 if(err == Z_OK) {
1929 fprintf(stderr," Geom Desc line1: %s\n",line1);
1930 fprintf(stderr," Geom Desc line2: %s\n",line2);
1932 else {
1933 fprintf(stderr,"Error: getting geom description lines\n");
1934 return(Z_ERR);
1937 #endif
1939 /* Get the number of model parts
1940 *------------------------------*/
1941 Num_parts = USERD_get_number_of_model_parts();
1942 if(Num_parts > 0) {
1943 fprintf(stderr," Number of parts: %d\n",Num_parts);
1945 else {
1946 fprintf(stderr," Problems getting number of parts\n");
1947 return(Z_ERR);
1952 /* Get the gold part build info
1953 *-----------------------------*/
1954 Pbuild = (BUILDINFO *) calloc(Num_parts,sizeof(BUILDINFO));
1955 if(Pbuild == (BUILDINFO *)NULL) {
1956 fprintf(stderr," Problems allocating for Pbuild structure\n");
1957 return(Z_ERR);
1961 part_ids = (int *) calloc(Num_parts,sizeof(int));
1962 if(part_ids == (int *)NULL) {
1963 fprintf(stderr," Problems allocating for part ids\n");
1964 return(Z_ERR);
1967 part_types = (int *) calloc(Num_parts,sizeof(int));
1968 if(part_types == (int *)NULL) {
1969 fprintf(stderr," Problems allocating for part types\n");
1970 return(Z_ERR);
1973 part_descriptions = (char **) calloc(Num_parts,sizeof(char *));
1974 if(part_descriptions == (char **)NULL) {
1975 fprintf(stderr," Problems allocating for part descriptions\n");
1976 return(Z_ERR);
1978 else {
1979 for(i=0; i<Num_parts; ++i) {
1980 part_descriptions[i] = (char *) calloc(Z_BUFL,sizeof(char));
1981 if(part_descriptions[i] == (char *)NULL) {
1982 fprintf(stderr," Problems allocating for part descriptions\n");
1983 return(Z_ERR);
1988 number_of_nodes = (int *) calloc(Num_parts,sizeof(int));
1989 if(number_of_nodes == (int *)NULL) {
1990 fprintf(stderr," Problems allocating for part number of nodes\n");
1991 return(Z_ERR);
1994 num_elems = (int **) calloc(Num_parts,sizeof(int *));
1995 if(num_elems == (int **)NULL) {
1996 fprintf(stderr," Problems allocating for part number of elements\n");
1997 return(Z_ERR);
1999 else {
2000 for(i=0; i<Num_parts; ++i) {
2001 num_elems[i] = (int *) calloc(Z_MAXTYPE,sizeof(int));
2002 if(num_elems[i] == (int *)NULL) {
2003 fprintf(stderr," Problems allocating for part number of elements\n");
2004 return(Z_ERR);
2009 ijk_dimensions = (int **) calloc(Num_parts,sizeof(int *));
2010 if(ijk_dimensions == (int **)NULL) {
2011 fprintf(stderr," Problems allocating for part ijk dimensions\n");
2012 return(Z_ERR);
2014 else {
2016 #if (defined GT_USERD_API_202)
2017 for(i=0; i<Num_parts; ++i) {
2018 ijk_dimensions[i] = (int *) calloc(9,sizeof(int));
2019 if(ijk_dimensions[i] == (int *)NULL) {
2020 fprintf(stderr," Problems allocating for part ijk dimensions\n");
2021 return(Z_ERR);
2023 else {
2024 for(j=0; j<9; ++j) {
2025 ijk_dimensions[i][j] = -1;
2029 #else
2030 for(i=0; i<Num_parts; ++i) {
2031 ijk_dimensions[i] = (int *) calloc(3,sizeof(int));
2032 if(ijk_dimensions[i] == (int *)NULL) {
2033 fprintf(stderr," Problems allocating for part ijk dimensions\n");
2034 return(Z_ERR);
2037 #endif
2040 iblanking_options = (int **) calloc(Num_parts,sizeof(int *));
2041 if(iblanking_options == (int **)NULL) {
2042 fprintf(stderr," Problems allocating for part iblanking options\n");
2043 return(Z_ERR);
2045 else {
2046 for(i=0; i<Num_parts; ++i) {
2047 iblanking_options[i] = (int *) calloc(6,sizeof(int));
2048 if(iblanking_options[i] == (int *)NULL) {
2049 fprintf(stderr," Problems allocating for part iblanking options\n");
2050 return(Z_ERR);
2056 #if (defined GT_USERD_API_100)
2058 err = USERD_get_gold_part_build_info(part_ids,
2059 part_types,
2060 part_descriptions,
2061 number_of_nodes,
2062 num_elems,
2063 ijk_dimensions,
2064 iblanking_options);
2065 #else
2067 err = USERD_get_part_build_info(part_ids,
2068 part_types,
2069 part_descriptions,
2070 num_elems,
2071 ijk_dimensions,
2072 iblanking_options);
2074 #endif
2076 if(err == Z_ERR) {
2077 fprintf(stderr," Problems getting part build info\n");
2078 return(Z_ERR);
2080 else {
2081 for(i=0; i<Num_parts; ++i) {
2082 fprintf(stderr," For part %d:\n",i+1);
2084 fprintf(stderr," part id: %d\n",part_ids[i]);
2085 Pbuild[i].id = part_ids[i];
2087 if(part_types[i] == Z_UNSTRUCTURED) {
2088 fprintf(stderr," part type: Z_UNSTRUCTURED\n");
2090 else if(part_types[i] == Z_STRUCTURED) {
2091 fprintf(stderr," part type: Z_STRUCTURED\n");
2093 else if(part_types[i] == Z_IBLANKED) {
2094 fprintf(stderr," part type: Z_IBLANKED\n");
2096 else {
2097 fprintf(stderr," Invalid part type\n");
2098 return(Z_ERR);
2100 Pbuild[i].type = part_types[i];
2102 fprintf(stderr," part desc: %s\n",part_descriptions[i]);
2103 strncpy(Pbuild[i].desc,part_descriptions[i],Z_BUFL);
2105 #if (defined GT_USERD_API_100)
2106 fprintf(stderr," number of nodes : %d\n",number_of_nodes[i]);
2107 Pbuild[i].nn = number_of_nodes[i];
2108 #else
2109 Pbuild[i].nn = USERD_get_number_of_global_nodes();
2110 #endif
2112 for(j=0; j<Z_MAXTYPE; ++j) {
2113 if(num_elems[i][j] > 0) {
2114 fprintf(stderr," # %s elements: %d\n",
2115 Elem_info[j].name,num_elems[i][j]);
2116 Pbuild[i].ne[j] = num_elems[i][j];
2120 if(part_types[i] != Z_UNSTRUCTURED) {
2122 /* For this checker, we will place the following in the
2123 * Pbuild[].ne[] structure:
2125 * Note this can be used for block size whether ranges or not
2126 * -------------------------------------------------------------
2127 * Pbuild[].ne[0] = i dim of current block (to the range selected)
2128 * Pbuild[].ne[1] = j dim of current block (to the range selected)
2129 * Pbuild[].ne[2] = k dim of current block (to the range selected)
2131 * Thus if ranges:
2132 * ---------------
2133 * Pbuild[].ne[3] = i min range (-1 indicates no ranges)
2134 * Pbuild[].ne[4] = i max range
2135 * Pbuild[].ne[5] = i min range
2136 * Pbuild[].ne[6] = i max range
2137 * Pbuild[].ne[7] = i min range
2138 * Pbuild[].ne[8] = i max range
2140 * Pbuild[].ne[9] = i dim of total block (if ranges)
2141 * Pbuild[].ne[10] = j dim of total block (if ranges)
2142 * Pbuild[].ne[11] = k dim of total block (if ranges)
2144 * What comes back from the api is:
2145 * --------------------------------
2146 * before 2.03 (no ranges)
2147 * -----------------------
2148 * ijk_dimensions[][0] = i dim of block
2149 * ijk_dimensions[][1] = j dim of block
2150 * ijk_dimensions[][2] = k dim of block
2152 * at 2.03 (if no ranges)
2153 * -------
2154 * ijk_dimensions[][0] = i dim of block
2155 * ijk_dimensions[][1] = j dim of block
2156 * ijk_dimensions[][2] = k dim of block
2157 * ijk_dimensions[][3] = -1
2159 * at 2.03 (if ranges)
2160 * -------
2161 * ijk_dimensions[][0] = i dim of total block
2162 * ijk_dimensions[][1] = j dim of total block
2163 * ijk_dimensions[][2] = k dim of total block
2164 * ijk_dimensions[][3] = i min range
2165 * ijk_dimensions[][4] = i max range
2166 * ijk_dimensions[][5] = j min range
2167 * ijk_dimensions[][6] = j max range
2168 * ijk_dimensions[][7] = k min range
2169 * ijk_dimensions[][8] = k max range
2170 *--------------------------------------------------------------*/
2172 #if (defined GT_USERD_API_202)
2173 if(ijk_dimensions[i][3] == -1) {
2174 fprintf(stderr," ijk_dimensions: %d %d %d\n",
2175 ijk_dimensions[i][0],
2176 ijk_dimensions[i][1],
2177 ijk_dimensions[i][2]);
2178 Pbuild[i].ne[0] = ijk_dimensions[i][0];
2179 Pbuild[i].ne[1] = ijk_dimensions[i][1];
2180 Pbuild[i].ne[2] = ijk_dimensions[i][2];
2181 Pbuild[i].ne[3] = ijk_dimensions[i][3];
2183 else {
2185 /* If empty part
2186 *--------------*/
2187 if(ijk_dimensions[i][0] == 0 &&
2188 ijk_dimensions[i][1] == 0 &&
2189 ijk_dimensions[i][2] == 0) {
2190 fprintf(stderr," ijk_dimensions: %d %d %d\n",
2191 ijk_dimensions[i][0],
2192 ijk_dimensions[i][1],
2193 ijk_dimensions[i][2]);
2194 Pbuild[i].ne[0] = ijk_dimensions[i][0];
2195 Pbuild[i].ne[1] = ijk_dimensions[i][1];
2196 Pbuild[i].ne[2] = ijk_dimensions[i][2];
2197 Pbuild[i].ne[3] = -1;
2200 /* range part
2201 *-----------*/
2202 else {
2203 Pbuild[i].ne[0] = ijk_dimensions[i][4] - ijk_dimensions[i][3] + 1;
2204 Pbuild[i].ne[1] = ijk_dimensions[i][6] - ijk_dimensions[i][5] + 1;
2205 Pbuild[i].ne[2] = ijk_dimensions[i][8] - ijk_dimensions[i][7] + 1;
2207 Pbuild[i].ne[3] = ijk_dimensions[i][3];
2208 Pbuild[i].ne[4] = ijk_dimensions[i][4];
2209 Pbuild[i].ne[5] = ijk_dimensions[i][5];
2210 Pbuild[i].ne[6] = ijk_dimensions[i][6];
2211 Pbuild[i].ne[7] = ijk_dimensions[i][7];
2212 Pbuild[i].ne[8] = ijk_dimensions[i][8];
2214 Pbuild[i].ne[9] = ijk_dimensions[i][0];
2215 Pbuild[i].ne[10] = ijk_dimensions[i][1];
2216 Pbuild[i].ne[11] = ijk_dimensions[i][2];
2218 fprintf(stderr," Part has ranges:\n");
2219 fprintf(stderr," ijk dimensions of total block: %d %d %d\n",
2220 Pbuild[i].ne[9],
2221 Pbuild[i].ne[10],
2222 Pbuild[i].ne[11]);
2223 fprintf(stderr," i range: %d to %d\n",
2224 Pbuild[i].ne[3],
2225 Pbuild[i].ne[4]);
2226 fprintf(stderr," j range: %d to %d\n",
2227 Pbuild[i].ne[5],
2228 Pbuild[i].ne[6]);
2229 fprintf(stderr," k range: %d to %d\n",
2230 Pbuild[i].ne[7],
2231 Pbuild[i].ne[8]);
2232 fprintf(stderr," ijk dimensions of range portion: %d %d %d\n",
2233 Pbuild[i].ne[0],
2234 Pbuild[i].ne[1],
2235 Pbuild[i].ne[2]);
2238 #else
2239 fprintf(stderr," ijk_dimensions: %d %d %d\n",
2240 ijk_dimensions[i][0],
2241 ijk_dimensions[i][1],
2242 ijk_dimensions[i][2]);
2243 Pbuild[i].ne[0] = ijk_dimensions[i][0];
2244 Pbuild[i].ne[1] = ijk_dimensions[i][1];
2245 Pbuild[i].ne[2] = ijk_dimensions[i][2];
2246 Pbuild[i].ne[3] = -1;
2247 #endif
2248 if(part_types[i] == Z_IBLANKED) {
2249 fprintf(stderr," Ibanking options on:\n");
2250 if(iblanking_options[i][Z_EXT]) {
2251 fprintf(stderr," Z_EXT\n");
2253 if(iblanking_options[i][Z_INT]) {
2254 fprintf(stderr," Z_INT\n");
2256 if(iblanking_options[i][Z_BND]) {
2257 fprintf(stderr," Z_BND\n");
2259 if(iblanking_options[i][Z_INTBND]) {
2260 fprintf(stderr," Z_INTBND\n");
2262 if(iblanking_options[i][Z_SYM]) {
2263 fprintf(stderr," Z_SYM\n");
2271 #if (defined GT_USERD_API_200)
2273 /* Get ghosts in model flag
2274 *-------------------------*/
2275 Ghosts_in_model = USERD_get_ghosts_in_model_flag();
2276 if(Ghosts_in_model) {
2277 fprintf(stderr," Ghosts in Model: TRUE\n");
2279 else {
2280 fprintf(stderr," Ghosts in Model: FALSE\n");
2283 /* Get ghosts in block flag - if needed
2284 *-------------------------------------*/
2285 for(i=1; i<=Num_parts; ++i) {
2286 if(part_types[i-1] != Z_UNSTRUCTURED && Ghosts_in_model) {
2287 ghosts_in_block = USERD_get_ghosts_in_block_flag(i);
2288 Pbuild[i-1].ghosts = ghosts_in_block;
2289 if(ghosts_in_block) {
2290 fprintf(stderr," Ghosts in block part %d: TRUE\n",i);
2292 else {
2293 fprintf(stderr," Ghosts in block part %d: FALSE\n",i);
2298 #endif
2301 #if (defined GT_USERD_API_100)
2303 /* Get maxsize info
2304 *-----------------*/
2305 max_num_nodes = (int *) calloc(Num_parts,sizeof(int));
2306 if(max_num_nodes == (int *)NULL) {
2307 fprintf(stderr," Problems allocating for part max num of nodes\n");
2308 return(Z_ERR);
2311 max_num_elems = (int **) calloc(Num_parts,sizeof(int *));
2312 if(max_num_elems == (int **)NULL) {
2313 fprintf(stderr," Problems allocating for part max num of elements\n");
2314 return(Z_ERR);
2316 else {
2317 for(i=0; i<Num_parts; ++i) {
2318 max_num_elems[i] = (int *) calloc(Z_MAXTYPE,sizeof(int));
2319 if(max_num_elems[i] == (int *)NULL) {
2320 fprintf(stderr," Problems allocating for part max_num of elements\n");
2321 return(Z_ERR);
2326 max_ijk_dimensions = (int **) calloc(Num_parts,sizeof(int *));
2327 if(max_ijk_dimensions == (int **)NULL) {
2328 fprintf(stderr," Problems allocating for part max ijk dimensions\n");
2329 return(Z_ERR);
2331 else {
2332 for(i=0; i<Num_parts; ++i) {
2333 max_ijk_dimensions[i] = (int *) calloc(3,sizeof(int));
2334 if(max_ijk_dimensions[i] == (int *)NULL) {
2335 fprintf(stderr," Problems allocating for part max ijk dimensions\n");
2336 return(Z_ERR);
2341 err = USERD_get_maxsize_info(max_num_nodes,
2342 max_num_elems,
2343 max_ijk_dimensions);
2344 if(err == Z_ERR) {
2345 fprintf(stderr," No maxsize info provided (or error getting them)\n");
2347 else {
2349 for(i=0; i<Num_parts; ++i) {
2350 fprintf(stderr," For part %d:\n",i+1);
2352 fprintf(stderr," max number of nodes : %d\n",max_num_nodes[i]);
2354 for(j=0; j<Z_MAXTYPE; ++j) {
2355 if(max_num_elems[i][j] > 0) {
2356 fprintf(stderr," max # %s elems: %d\n",
2357 Elem_info[j].name,max_num_elems[i][j]);
2361 if(part_types[i] != Z_UNSTRUCTURED) {
2362 fprintf(stderr," max_ijk_dimensions: %d %d %d\n",
2363 max_ijk_dimensions[i][0],
2364 max_ijk_dimensions[i][1],
2365 max_ijk_dimensions[i][2]);
2370 /* Get model extents - if given
2371 *-----------------------------*/
2372 err = USERD_get_model_extents(extents);
2373 if(err == Z_ERR) {
2374 fprintf(stderr," No extents given\n");
2376 else {
2377 fprintf(stderr," Min x: %g\n",extents[0]);
2378 fprintf(stderr," Max x: %g\n",extents[1]);
2379 fprintf(stderr," Min y: %g\n",extents[2]);
2380 fprintf(stderr," Max y: %g\n",extents[3]);
2381 fprintf(stderr," Min z: %g\n",extents[4]);
2382 fprintf(stderr," Max z: %g\n",extents[5]);
2385 #endif
2387 /* Free the allocated memory
2388 *--------------------------*/
2389 free(part_ids);
2390 free(part_types);
2391 free(number_of_nodes);
2393 for(i=0; i<Num_parts; ++i) {
2394 free(ijk_dimensions[i]);
2395 free(num_elems[i]);
2396 free(part_descriptions[i]);
2398 free(ijk_dimensions);
2399 free(num_elems);
2400 free(iblanking_options);
2401 free(part_descriptions);
2403 #if (defined GT_USERD_API_100)
2404 for(i=0; i<Num_parts; ++i) {
2405 free(max_ijk_dimensions[i]);
2406 free(max_num_elems[i]);
2408 free(max_num_nodes);
2409 free(max_num_elems);
2410 free(max_ijk_dimensions);
2412 #endif
2414 return(Z_OK);
2418 /*--------------
2419 * variable_info
2420 *--------------*/
2421 static int
2422 variable_info( void )
2424 int i,j;
2425 int err;
2427 char **var_description;
2428 char **var_filename;
2429 int *var_type;
2430 int *var_classify;
2431 int *var_complex;
2432 char **var_ifilename;
2433 float *var_freq;
2434 int *var_contran;
2435 int *var_timeset;
2438 fprintf(stderr,"\n------------ variable_info --------------\n");
2440 /* Get the number of variables
2441 *----------------------------*/
2442 Num_vars = USERD_get_number_of_variables();
2443 if(Num_vars < 0) {
2444 fprintf(stderr,"Error: getting the number of variables\n");
2446 else {
2447 fprintf(stderr," Number of variables: %d\n",Num_vars);
2451 /* Get the gold variable info
2452 *---------------------------*/
2453 Varinfo = (VARINFO *) calloc(Num_vars,sizeof(VARINFO));
2454 if(Varinfo == (VARINFO *)NULL) {
2455 fprintf(stderr," Problems allocating for Varinfo structure\n");
2456 return(Z_ERR);
2460 var_description = (char **) calloc(Num_vars,sizeof(char *));
2461 if(var_description == (char **)NULL) {
2462 fprintf(stderr," Problems allocating for var description\n");
2463 return(Z_ERR);
2465 else {
2466 for(i=0; i<Num_vars; ++i) {
2467 var_description[i] = (char *) calloc(Z_BUFL,sizeof(char));
2468 if(var_description[i] == (char *)NULL) {
2469 fprintf(stderr," Problems allocating for var description\n");
2470 return(Z_ERR);
2475 var_filename = (char **) calloc(Num_vars,sizeof(char *));
2476 if(var_filename == (char **)NULL) {
2477 fprintf(stderr," Problems allocating for var filename\n");
2478 return(Z_ERR);
2480 else {
2481 for(i=0; i<Num_vars; ++i) {
2482 var_filename[i] = (char *) calloc(Z_BUFL,sizeof(char));
2483 if(var_filename[i] == (char *)NULL) {
2484 fprintf(stderr," Problems allocating for var filename\n");
2485 return(Z_ERR);
2490 var_type = (int *) calloc(Num_vars,sizeof(int));
2491 if(var_type == (int *)NULL) {
2492 fprintf(stderr," Problems allocating for var type\n");
2493 return(Z_ERR);
2496 var_classify = (int *) calloc(Num_vars,sizeof(int));
2497 if(var_classify == (int *)NULL) {
2498 fprintf(stderr," Problems allocating for var classify\n");
2499 return(Z_ERR);
2502 var_complex = (int *) calloc(Num_vars,sizeof(int));
2503 if(var_complex == (int *)NULL) {
2504 fprintf(stderr," Problems allocating for var complex\n");
2505 return(Z_ERR);
2509 var_ifilename = (char **) calloc(Num_vars,sizeof(char *));
2510 if(var_ifilename == (char **)NULL) {
2511 fprintf(stderr," Problems allocating for var ifilename\n");
2512 return(Z_ERR);
2514 else {
2515 for(i=0; i<Num_vars; ++i) {
2516 var_ifilename[i] = (char *) calloc(Z_BUFL,sizeof(char));
2517 if(var_ifilename[i] == (char *)NULL) {
2518 fprintf(stderr," Problems allocating for var ifilename\n");
2519 return(Z_ERR);
2524 var_freq = (float *) calloc(Num_vars,sizeof(float));
2525 if(var_freq == (float *)NULL) {
2526 fprintf(stderr," Problems allocating for var freq\n");
2527 return(Z_ERR);
2530 var_contran = (int *) calloc(Num_vars,sizeof(int));
2531 if(var_contran == (int *)NULL) {
2532 fprintf(stderr," Problems allocating for var contran\n");
2533 return(Z_ERR);
2536 var_timeset = (int *) calloc(Num_vars,sizeof(int));
2537 if(var_timeset == (int *)NULL) {
2538 fprintf(stderr," Problems allocating for var timeset\n");
2539 return(Z_ERR);
2542 #if (defined GT_USERD_API_100)
2544 err = USERD_get_gold_variable_info(var_description,
2545 var_filename,
2546 var_type,
2547 var_classify,
2548 var_complex,
2549 var_ifilename,
2550 var_freq,
2551 var_contran,
2552 var_timeset);
2553 #else
2555 err = USERD_get_variable_info(var_description,
2556 var_filename,
2557 var_type,
2558 var_classify);
2560 #endif
2562 if(err == Z_ERR) {
2563 fprintf(stderr,"Error: getting variable info\n");
2565 else {
2566 for(i=0; i<Num_vars; ++i) {
2568 /* Loading the global
2569 * (for use in other routines)
2570 *----------------------------*/
2571 strncpy(Varinfo[i].description,var_description[i],Z_BUFL);
2572 strncpy(Varinfo[i].filename,var_filename[i],Z_BUFL);
2573 strncpy(Varinfo[i].ifilename,var_ifilename[i],Z_BUFL);
2574 Varinfo[i].type = var_type[i];
2575 Varinfo[i].classify = var_classify[i];
2576 Varinfo[i].complex = var_complex[i];
2577 Varinfo[i].freq = var_freq[i];
2578 Varinfo[i].contran = var_contran[i];
2579 Varinfo[i].timeset = var_timeset[i];
2581 /* Echo some feedback
2582 *-------------------*/
2583 fprintf(stderr," For Variable %d:\n",i+1);
2585 fprintf(stderr," var desc: %s\n",var_description[i]);
2586 fprintf(stderr," var filename: %s\n",var_filename[i]);
2588 #if (defined GT_USERD_API_100)
2589 if(var_complex[i]) {
2590 fprintf(stderr," var complex: TRUE\n");
2591 fprintf(stderr," var ifilename: %s\n",var_ifilename[i]);
2592 fprintf(stderr," var freq: %g\n",var_freq[i]);
2594 else {
2595 fprintf(stderr," var complex: FALSE\n");
2597 #endif
2599 if(var_type[i] == Z_CONSTANT) {
2600 fprintf(stderr," var type: Z_CONSTANT\n");
2602 #if (defined GT_USERD_API_100)
2603 if(var_contran[i]) {
2604 fprintf(stderr," var contran: TRUE\n");
2606 else {
2607 fprintf(stderr," var contran: FALSE\n");
2609 #endif
2612 else if(var_type[i] == Z_SCALAR) {
2613 fprintf(stderr," var type: Z_SCALAR\n");
2615 else if(var_type[i] == Z_VECTOR) {
2616 fprintf(stderr," var type: Z_VECTOR\n");
2618 else if(var_type[i] == Z_TENSOR) {
2619 fprintf(stderr," var type: Z_TENSOR\n");
2621 else if(var_type[i] == Z_TENSOR9) {
2622 fprintf(stderr," var type: Z_TENSOR9\n");
2624 else {
2625 fprintf(stderr," Invalid var type\n");
2626 return(Z_ERR);
2629 if(var_classify[i] == Z_PER_NODE) {
2630 fprintf(stderr," var classify: Z_PER_NODE\n");
2632 else if(var_classify[i] == Z_PER_ELEM) {
2633 fprintf(stderr," var classify: Z_PER_ELEM\n");
2635 else if(var_classify[i] != Z_CONSTANT) {
2636 fprintf(stderr," Invalid var classify\n");
2637 return(Z_ERR);
2640 #if (defined GT_USERD_API_100)
2641 fprintf(stderr," var timeset: %d\n",var_timeset[i]);
2642 #endif
2646 /* Free the allocated memory
2647 *--------------------------*/
2648 for(i=0; i<Num_vars; ++i) {
2649 free(var_description[i]);
2650 free(var_filename[i]);
2651 free(var_ifilename[i]);
2653 free(var_description);
2654 free(var_filename);
2655 free(var_ifilename);
2656 free(var_type);
2657 free(var_classify);
2658 free(var_complex);
2659 free(var_freq);
2660 free(var_contran);
2661 free(var_timeset);
2663 return(Z_OK);
2667 #if (defined GT_USERD_API_100)
2668 /*------------------
2669 * gold_part_builder
2670 *------------------*/
2671 static int
2672 gold_part_builder(int geom_time_step)
2674 int i, j, k, jj, kk;
2675 int err;
2676 int geom_timeset;
2677 int p, pn;
2678 int et, ne;
2679 int *elemids;
2680 int **conns;
2681 int nn;
2682 int comp;
2683 int bdim[3];
2684 int ib[5];
2685 int num_ghosts;
2686 int num_dims;
2687 int cell_type;
2688 float mm[6];
2689 float **coords;
2690 int *nodeids;
2691 int *iblanking;
2692 int *ghost_flag;
2693 short *parent_type;
2694 int *parent_num;
2695 int num_elems[Z_MAXTYPE];
2696 CRD *crds;
2697 int bd1,bd2,bd3;
2698 int empty_part;
2699 int *pdata;
2700 int nsid_len;
2701 int *nsid_con;
2702 int nface_len;
2703 int *nface_con;
2704 int npf_len;
2705 int *npf_con;
2706 int maxcheck;
2707 int num_failed = 0;
2708 int *fail_flags = (int *) NULL;
2709 float values[14], vals[10];
2711 fprintf(stderr,"\n------------- part_builder --------------\n");
2713 if(Num_time_sets > 0) {
2714 /* Get the timeset used for the geometry
2715 *--------------------------------------*/
2716 geom_timeset = USERD_get_geom_timeset_number();
2718 /* Get the number of time steps for this timeset
2719 *----------------------------------------------*/
2720 Num_time_steps = USERD_get_num_of_time_steps(geom_timeset);
2721 if(Num_time_steps < 1) {
2722 fprintf(stderr," Error: Number of time steps returned: %d\n",Num_time_steps);
2723 fprintf(stderr," (Must be >0 to be okay)\n");
2724 return(Z_ERR);
2726 if(geom_time_step > (Num_time_steps - 1)) {
2727 geom_time_step = Num_time_steps - 1;
2730 /* Set the timeset and step - to first step by default, but
2731 * can set it at others using -gts command argument
2732 *---------------------------------------------------------*/
2733 USERD_set_time_set_and_step(geom_timeset,geom_time_step);
2735 fprintf(stderr," Using timeset: %d (step range is %d through %d)\n",
2736 geom_timeset,0,Num_time_steps-1);
2737 fprintf(stderr," Using time step: %d\n",geom_time_step);
2740 for(p=0; p<Num_parts; ++p) {
2741 pn = p+1;
2743 fprintf(stderr,"\n\n----------------------------------------");
2744 fprintf(stderr," Part %d:\n",pn);
2746 /*-----------------------
2747 * For unstructured parts
2748 *-----------------------*/
2749 if(Pbuild[p].type == Z_UNSTRUCTURED) {
2751 for(et=0; et<Z_MAXTYPE; ++et) {
2752 ne = Pbuild[p].ne[et];
2754 if(ne > 0) {
2756 pdata = (int *)calloc(ne*Elem_info[et].con_len,sizeof(int));
2757 if(pdata == (int *) NULL) {
2758 fprintf(stderr,"Error: allocating conns array\n");
2759 return(Z_ERR);
2761 else {
2762 conns = (int **) calloc(ne,sizeof(int *));
2763 if(conns == (int **) NULL) {
2764 fprintf(stderr,"Error: allocating conns array\n");
2765 return(Z_ERR);
2767 for(i=0; i<ne; ++i) {
2768 conns[i] = pdata;
2769 pdata += Elem_info[et].con_len;
2774 /* Get the elements
2775 *-----------------*/
2776 err = USERD_get_part_elements_by_type(pn,et,conns);
2777 if(err == Z_ERR) {
2778 fprintf(stderr,"Error: getting element connectivities\n");
2779 return(Z_ERR);
2782 if(Element_labels) {
2783 elemids = (int *) calloc(ne,sizeof(int));
2784 if(elemids == (int *) NULL) {
2785 fprintf(stderr,"Error: allocating elemids array\n");
2786 return(Z_ERR);
2790 /* Get the element ids - if any
2791 *-----------------------------*/
2792 if(Element_labels) {
2793 err = USERD_get_part_element_ids_by_type(pn,et,elemids);
2794 if(err == Z_ERR) {
2795 fprintf(stderr,"Error: getting element ids\n");
2796 return(Z_ERR);
2800 /* Echo "some" info
2801 *-----------------*/
2803 #if (defined GT_USERD_API_202)
2805 maxcheck = Z_NSIDED;
2807 /* Nsided elements, if any
2808 *------------------------*/
2809 if(et == Z_NSIDED ||
2810 et == Z_G_NSIDED) {
2812 nsid_len = 0;
2813 for(i=0; i<ne; ++i) {
2814 nsid_len += conns[i][0];
2817 nsid_con = (int *) calloc(nsid_len,sizeof(int));
2818 if(nsid_con == (int *) NULL) {
2819 fprintf(stderr,"Error: allocating nsided conn array\n");
2820 return(Z_ERR);
2823 err = USERD_get_nsided_conn(pn,nsid_con);
2824 if(err == Z_ERR) {
2825 fprintf(stderr,"Error: getting nsided conn array\n");
2826 return(Z_ERR);
2829 /* First element of the type
2830 *--------------------------*/
2831 i = 0;
2832 fprintf(stderr," %s Element %d of %d:\n",Elem_info[et].name,i+1,ne);
2833 if(Element_labels) {
2834 fprintf(stderr," id: %d\n",elemids[i]);
2836 fprintf(stderr," connectivity:");
2837 for(j=0; j<conns[i][0]; ++j) {
2838 fprintf(stderr," %d",nsid_con[j]);
2840 fprintf(stderr,"\n");
2842 /* Last element of the type
2843 *-------------------------*/
2844 i = ne - 1;
2845 if(i > 0) {
2846 fprintf(stderr," %s Element %d of %d:\n",Elem_info[et].name,i+1,ne);
2847 if(Element_labels) {
2848 fprintf(stderr," id: %d\n",elemids[i]);
2850 fprintf(stderr," connectivity:");
2852 for(j=nsid_len-conns[i][0]; j<nsid_len; ++j) {
2853 fprintf(stderr," %d",nsid_con[j]);
2855 fprintf(stderr,"\n");
2859 /* Nfaced elements if any
2860 *-----------------------*/
2861 if(et == Z_NFACED ||
2862 et == Z_G_NFACED) {
2864 nface_len = 0;
2865 for(i=0; i<ne; ++i) {
2866 nface_len += conns[i][0];
2869 nface_con = (int *) calloc(nface_len,sizeof(int));
2870 if(nface_con == (int *) NULL) {
2871 fprintf(stderr,"Error: allocating nfaced face array\n");
2872 return(Z_ERR);
2875 err = USERD_get_nfaced_nodes_per_face(pn,nface_con);
2876 if(err == Z_ERR) {
2877 fprintf(stderr,"Error: getting nfaced face array array\n");
2878 return(Z_ERR);
2881 npf_len = 0;
2882 for(i=0; i<nface_len; ++i) {
2883 npf_len += nface_con[i];
2886 npf_con = (int *) calloc(npf_len,sizeof(int));
2887 if(npf_con == (int *) NULL) {
2888 fprintf(stderr,"Error: allocating nfaced npf array\n");
2889 return(Z_ERR);
2892 err = USERD_get_nfaced_conn(pn,npf_con);
2893 if(err == Z_ERR) {
2894 fprintf(stderr,"Error: getting nfaced conn array\n");
2895 return(Z_ERR);
2898 /* First element of the type
2899 *--------------------------*/
2900 jj = 0;
2901 kk = 0;
2902 for(i=0; i<ne; ++i) {
2904 if(i == 0 ||
2905 i == ne-1) {
2906 fprintf(stderr," %s Element %d of %d:\n",Elem_info[et].name,
2907 i+1,ne);
2908 if(Element_labels) {
2909 fprintf(stderr," id: %d\n",elemids[i]);
2911 for(j=0; j<conns[i][0]; ++j) {
2912 fprintf(stderr," face %d connectivity:",j+1);
2913 for(k=0; k<nface_con[jj]; ++k) {
2914 fprintf(stderr," %d",npf_con[kk]);
2915 ++kk;
2917 fprintf(stderr,"\n");
2918 ++jj;
2921 else {
2922 for(j=0; j<conns[i][0]; ++j) {
2923 for(k=0; k<nface_con[jj]; ++k) {
2924 ++kk;
2926 ++jj;
2931 #else
2933 maxcheck = Z_MAXTYPE;
2935 #endif
2937 /* Regular elements
2938 *-----------------*/
2939 if(et < maxcheck) {
2941 /* First element of the type
2942 *--------------------------*/
2943 i = 0;
2944 fprintf(stderr," %s Element %d of %d:\n",Elem_info[et].name,i+1,ne);
2945 if(Element_labels) {
2946 fprintf(stderr," id: %d\n",elemids[i]);
2948 fprintf(stderr," connectivity:");
2949 for(j=0; j<Elem_info[et].con_len; ++j) {
2950 fprintf(stderr," %d",conns[i][j]);
2952 fprintf(stderr,"\n");
2954 /* check the connectivity for negative numbers
2955 * -------------------------------------------*/
2956 #if defined GT_USERD_API_100
2957 for (i=0;i<ne;i++){
2958 for(j=0; j<Elem_info[et].con_len; ++j) {
2959 /* ---------- uncomment to print out connectivity values ---------- */
2960 /* fprintf(stderr," %d",conns[i][j]); */
2961 if (conns[i][j] <= 0 || conns[i][j] > Pbuild[p].nn ) {
2962 fprintf(stderr,"\n****************************\n");
2963 fprintf(stderr,"Connectivity value out of bounds: \n");
2964 fprintf(stderr,"Either less than zero or greater than \n");
2965 fprintf(stderr," number of nodes in part!! \n");
2966 fprintf(stderr,"i = %d j = %d conns[i][j] = %d \n",i,j,conns[i][j]);
2967 fprintf(stderr,"****************************\n");
2970 /* ---------- uncomment to print out connectivity values ---------- */
2971 /* fprintf(stderr,"\n"); */
2973 #endif
2974 /* Last element of the type
2975 *-------------------------*/
2976 i = ne - 1;
2977 if(i > 0) {
2978 fprintf(stderr," %s Element %d of %d:\n",Elem_info[et].name,i+1,ne);
2979 if(Element_labels) {
2980 fprintf(stderr," id: %d\n",elemids[i]);
2982 fprintf(stderr," connectivity:");
2983 for(j=0; j<Elem_info[et].con_len; ++j) {
2984 fprintf(stderr," %d",conns[i][j]);
2986 fprintf(stderr,"\n");
2990 /* Free the allocated memory
2991 *--------------------------*/
2992 if(NULL != conns) {
2993 if(NULL != *conns) {
2994 free(*conns);
2995 *conns = NULL;
2997 free(conns);
2998 conns = NULL;
3001 if(Element_labels) {
3002 free(elemids);
3007 /* Get the coords
3008 *---------------*/
3009 nn = Pbuild[p].nn;
3011 if(nn > 0) {
3013 coords = (float **) calloc(3,sizeof(float *));
3014 if(coords == (float **) NULL) {
3015 fprintf(stderr,"Error: allocating coords array\n");
3016 return(Z_ERR);
3018 else {
3019 for(i=0; i<3; ++i) {
3020 coords[i] = (float *) calloc((nn+1),sizeof(float));
3021 if(coords[i] == (float *) NULL) {
3022 fprintf(stderr,"Error: allocating coords array\n");
3023 return(Z_ERR);
3028 if(Node_labels) {
3029 nodeids = (int *) calloc((nn+1),sizeof(int));
3030 if(nodeids == (int *) NULL) {
3031 fprintf(stderr,"Error: allocating nodeids array\n");
3032 return(Z_ERR);
3037 err = USERD_get_part_coords(pn,coords);
3038 if(err == Z_ERR) {
3039 fprintf(stderr,"Error: getting unstructured coords\n");
3040 return(Z_ERR);
3043 if(Node_labels) {
3044 err = USERD_get_part_node_ids(pn,nodeids);
3045 if(err == Z_ERR) {
3046 fprintf(stderr,"Error: getting nodeids\n");
3047 return(Z_ERR);
3051 /* Echo "some" info
3052 *-----------------*/
3054 /* First node
3055 *-----------*/
3056 i = 1;
3057 fprintf(stderr," Node %d of %d:\n",i,nn);
3058 if(Node_labels) {
3059 fprintf(stderr," id: %d\n",nodeids[i]);
3061 fprintf(stderr," x y z coordinates: %g %g %g\n",
3062 coords[0][i], coords[1][i], coords[2][i]);
3063 mm[0] = mm[1] = coords[0][i];
3064 mm[2] = mm[3] = coords[1][i];
3065 mm[4] = mm[5] = coords[2][i];
3068 /* Last node
3069 *----------*/
3070 i = nn;
3071 if(i > 1) {
3072 fprintf(stderr," Node %d of %d:\n",i,nn);
3073 if(Node_labels) {
3074 fprintf(stderr," id: %d\n",nodeids[i]);
3076 fprintf(stderr," x y z coordinates: %g %g %g\n",
3077 coords[0][i], coords[1][i], coords[2][i]);
3080 /* Min and max coordinate values
3081 *------------------------------*/
3082 for(i=2; i<=nn; ++i) {
3083 if(coords[0][i] < mm[0]) {
3084 mm[0] = coords[0][i];
3086 if(coords[0][i] > mm[1]) {
3087 mm[1] = coords[0][i];
3089 if(coords[1][i] < mm[2]) {
3090 mm[2] = coords[1][i];
3092 if(coords[1][i] > mm[3]) {
3093 mm[3] = coords[1][i];
3095 if(coords[2][i] < mm[4]) {
3096 mm[4] = coords[2][i];
3098 if(coords[2][i] > mm[5]) {
3099 mm[5] = coords[2][i];
3103 fprintf(stderr," Coordinate ranges:\n");
3104 fprintf(stderr," min x: %g\n",mm[0]);
3105 fprintf(stderr," max x: %g\n",mm[1]);
3106 fprintf(stderr," min y: %g\n",mm[2]);
3107 fprintf(stderr," max y: %g\n",mm[3]);
3108 fprintf(stderr," min z: %g\n",mm[4]);
3109 fprintf(stderr," max z: %g\n",mm[5]);
3112 /* Free the allocated memory
3113 *--------------------------*/
3114 for(i=0; i<3; ++i) {
3115 free(coords[i]);
3117 free(coords);
3118 if(Node_labels) {
3119 free(nodeids);
3125 /*---------------------
3126 * For structured parts
3127 *---------------------*/
3128 else {
3130 empty_part = FALSE;
3131 if(Pbuild[p].ne[0] == 0 &&
3132 Pbuild[p].ne[1] == 0 &&
3133 Pbuild[p].ne[2] == 0) {
3134 empty_part = TRUE;
3137 if(!empty_part) {
3139 /* Get the block coords
3140 *---------------------*/
3141 for(comp=0; comp<3; ++comp) {
3142 if(Pbuild[p].ne[comp] < 1) {
3143 bdim[comp] = 1;
3145 else {
3147 if(Doing_Structured_Cinching) {
3148 bdim[comp] = Pbuild[p].ne[comp];
3150 /* even */
3151 if((bdim[comp] % 2) == 0) {
3152 bdim[comp] = (bdim[comp]/2) + 1;
3154 /* odd */
3155 else {
3156 bdim[comp] = ((bdim[comp]-1)/2) + 1;
3160 else {
3161 bdim[comp] = Pbuild[p].ne[comp];
3166 nn = bdim[0] * bdim[1] * bdim[2];
3168 bd1 = bdim[0]-1;
3169 if(bd1 < 1) {
3170 bd1 = 1;
3172 bd2 = bdim[1]-1;
3173 if(bd2 < 1) {
3174 bd2 = 1;
3176 bd3 = bdim[2]-1;
3177 if(bd3 < 1) {
3178 bd3 = 1;
3180 ne = bd1 * bd2 * bd3;
3182 /* Determine cell type
3183 *--------------------*/
3184 num_dims = 3;
3185 for(i=0; i<3; ++i) {
3186 if(bdim[i] == 1) {
3187 --num_dims;
3190 if(num_dims == 3) {
3191 cell_type = Z_HEX08;
3193 else if(num_dims == 2) {
3194 cell_type = Z_QUA04;
3196 else {
3197 cell_type = Z_BAR02;
3200 coords = (float **) calloc(num_dims,sizeof(float *));
3201 if(coords == (float **) NULL) {
3202 fprintf(stderr,"Error: allocating coords array\n");
3203 return(Z_ERR);
3205 else {
3206 for(i=0; i<num_dims; ++i) {
3207 coords[i] = (float *) calloc(nn,sizeof(float));
3208 if(coords[i] == (float *) NULL) {
3209 fprintf(stderr,"Error: allocating coords array\n");
3210 return(Z_ERR);
3215 /* Get the coords
3216 *---------------*/
3217 for(comp=0; comp<num_dims; ++comp) {
3219 /* For structured cinching, send in one less on each end and stride of 2
3220 *----------------------------------------------------------------------*/
3221 if(Doing_Structured_Cinching) {
3222 err = USERD_set_block_range_and_stride(pn,
3223 0, Pbuild[p].ne[0]-1, 2,
3224 0, Pbuild[p].ne[1]-1, 2,
3225 0, Pbuild[p].ne[2]-1, 2);
3228 err = USERD_get_block_coords_by_component(pn,comp,coords[comp]);
3229 if(err == Z_ERR) {
3230 fprintf(stderr,"Error: getting block coords\n");
3231 return(Z_ERR);
3236 #if (defined GT_USERD_API_200)
3238 if(Node_labels) {
3239 nodeids = (int *) calloc(nn,sizeof(int));
3240 if(nodeids == (int *) NULL) {
3241 fprintf(stderr,"Error: allocating nodeids array\n");
3242 return(Z_ERR);
3245 /* Get the node ids - if any
3246 *--------------------------*/
3247 if(Node_labels) {
3248 err = USERD_get_part_node_ids(pn,nodeids);
3249 if(err == Z_ERR) {
3250 fprintf(stderr,"Error: getting nodeids\n");
3251 return(Z_ERR);
3254 #endif
3256 /* Echo "some" info
3257 *-----------------*/
3259 /* First node
3260 *-----------*/
3261 if(nn > 0) {
3262 i = 0;
3263 fprintf(stderr," Node %d of %d:\n",i+1,nn);
3265 #if (defined GT_USERD_API_200)
3267 if(Node_labels) {
3268 fprintf(stderr," id: %d\n",nodeids[i]);
3270 #endif
3271 if(num_dims == 3) {
3272 fprintf(stderr," x y z coordinates: %g %g %g\n",
3273 coords[0][i], coords[1][i], coords[2][i]);
3274 mm[0] = mm[1] = coords[0][i];
3275 mm[2] = mm[3] = coords[1][i];
3276 mm[4] = mm[5] = coords[2][i];
3278 else if(num_dims == 2) {
3279 fprintf(stderr," x y coordinates: %g %g\n",
3280 coords[0][i], coords[1][i]);
3281 mm[0] = mm[1] = coords[0][i];
3282 mm[2] = mm[3] = coords[1][i];
3284 else {
3285 fprintf(stderr," x coordinates: %g\n",
3286 coords[0][i]);
3287 mm[0] = mm[1] = coords[0][i];
3291 /* Last node
3292 *----------*/
3293 i = nn-1;
3294 if(i > 1) {
3295 fprintf(stderr," Node %d of %d:\n",i+1,nn);
3297 #if (defined GT_USERD_API_200)
3298 if(Node_labels) {
3299 fprintf(stderr," id: %d\n",nodeids[i]);
3301 #endif
3302 if(num_dims == 3) {
3303 fprintf(stderr," x y z coordinates: %g %g %g\n",
3304 coords[0][i], coords[1][i], coords[2][i]);
3306 else if(num_dims == 2) {
3307 fprintf(stderr," x y coordinates: %g %g\n",
3308 coords[0][i], coords[1][i]);
3310 else {
3311 fprintf(stderr," x coordinates: %g\n",
3312 coords[0][i]);
3317 /* Min and max coordinate values
3318 *------------------------------*/
3319 for(i=1; i<nn; ++i) {
3320 if(coords[0][i] < mm[0]) {
3321 mm[0] = coords[0][i];
3323 if(coords[0][i] > mm[1]) {
3324 mm[1] = coords[0][i];
3326 if(num_dims > 1) {
3327 if(coords[1][i] < mm[2]) {
3328 mm[2] = coords[1][i];
3330 if(coords[1][i] > mm[3]) {
3331 mm[3] = coords[1][i];
3334 if(num_dims > 2) {
3335 if(coords[2][i] < mm[4]) {
3336 mm[4] = coords[2][i];
3338 if(coords[2][i] > mm[5]) {
3339 mm[5] = coords[2][i];
3344 fprintf(stderr," Coordinate ranges:\n");
3345 fprintf(stderr," min x: %g\n",mm[0]);
3346 fprintf(stderr," max x: %g\n",mm[1]);
3347 if(num_dims > 1) {
3348 fprintf(stderr," min y: %g\n",mm[2]);
3349 fprintf(stderr," max y: %g\n",mm[3]);
3351 if(num_dims > 2) {
3352 fprintf(stderr," min z: %g\n",mm[4]);
3353 fprintf(stderr," max z: %g\n",mm[5]);
3356 /* Free the allocated memory - so far
3357 *-----------------------------------*/
3358 for(i=0; i<num_dims; ++i) {
3359 free(coords[i]);
3361 free(coords);
3363 #if (defined GT_USERD_API_200)
3364 if(Node_labels) {
3365 free(nodeids);
3367 #endif
3369 /* Get the block iblanking - if any
3370 *---------------------------------*/
3371 if(Pbuild[p].type == Z_IBLANKED) {
3373 iblanking = (int *) calloc(nn,sizeof(int));
3374 if(iblanking == (int *) NULL) {
3375 fprintf(stderr,"Error: allocating iblanking array\n");
3376 return(Z_ERR);
3379 err = USERD_get_block_iblanking(pn,iblanking);
3380 if(err == Z_ERR) {
3381 fprintf(stderr,"Error: getting block iblanking\n");
3382 return(Z_ERR);
3385 /* Echo "some" info
3386 *-----------------*/
3387 ib[Z_EXT] = 0;
3388 ib[Z_INT] = 0;
3389 ib[Z_BND] = 0;
3390 ib[Z_INTBND] = 0;
3391 ib[Z_SYM] = 0;
3393 for(i=0; i<nn; ++i) {
3394 ++ib[iblanking[i]];
3397 fprintf(stderr," Iblanking breakdown:\n");
3398 fprintf(stderr," Number of Z_EXT: %d\n",ib[Z_EXT]);
3399 fprintf(stderr," Number of Z_INT: %d\n",ib[Z_INT]);
3400 fprintf(stderr," Number of Z_BND: %d\n",ib[Z_BND]);
3401 fprintf(stderr," Number of Z_INTBND: %d\n",ib[Z_INTBND]);
3402 fprintf(stderr," Number of Z_SYM: %d\n",ib[Z_SYM]);
3404 free(iblanking);
3407 #if (defined GT_USERD_API_200)
3409 /* Get the ghost flags - if any
3410 *-----------------------------*/
3411 if(Pbuild[p].ghosts) {
3413 ghost_flag = (int *) calloc(ne,sizeof(int));
3414 if(ghost_flag == (int *) NULL) {
3415 fprintf(stderr,"Error: allocating ghost_flag array\n");
3416 return(Z_ERR);
3419 err = USERD_get_block_ghost_flags(pn,ghost_flag);
3420 if(err == Z_ERR) {
3421 fprintf(stderr,"Error: getting block ghost flags\n");
3422 return(Z_ERR);
3425 /* Echo "some" info
3426 *-----------------*/
3427 num_ghosts = 0;
3429 for(i=0; i<ne; ++i) {
3430 if(ghost_flag[i] > 0) {
3431 ++num_ghosts;
3435 fprintf(stderr," Block Ghost flag breakdown:\n");
3436 fprintf(stderr," %d ghost cells out of %d total cells\n",
3437 num_ghosts,ne);
3439 free(ghost_flag);
3442 /* Get the element ids - if any
3443 *-----------------------------*/
3444 if(Element_labels) {
3446 elemids = (int *) calloc(ne,sizeof(int));
3447 if(elemids == (int *) NULL) {
3448 fprintf(stderr,"Error: allocating elemids array\n");
3449 return(Z_ERR);
3453 et = cell_type;
3454 err = USERD_get_part_element_ids_by_type(pn,et,elemids);
3455 if(err == Z_ERR) {
3456 fprintf(stderr,"Error: getting element ids\n");
3457 return(Z_ERR);
3460 /* First element of the type
3461 *--------------------------*/
3462 i = 0;
3463 fprintf(stderr," %s Element %d of %d:\n",Elem_info[et].name,i+1,ne);
3464 fprintf(stderr," id: %d\n",elemids[i]);
3466 /* Last element of the type
3467 *-------------------------*/
3468 i = ne - 1;
3469 if(i > 0) {
3470 fprintf(stderr," %s Element %d of %d:\n",Elem_info[et].name,i+1,ne);
3471 fprintf(stderr," id: %d\n",elemids[i]);
3474 free(elemids);
3476 #endif
3478 else {
3479 fprintf(stderr," Empty structured part\n");
3483 /* Get border availability
3484 *------------------------*/
3485 err = USERD_get_border_availability(pn,num_elems);
3486 if(err == Z_OK) {
3488 /* Get border elements - if any
3489 *-----------------------------*/
3490 for(et=0; et<Z_MAXTYPE; ++et) {
3491 ne = num_elems[et];
3492 if(ne > 0) {
3494 conns = (int **) calloc(ne,sizeof(int *));
3495 if(conns == (int **) NULL) {
3496 fprintf(stderr,"Error: allocating border conns array\n");
3497 return(Z_ERR);
3499 else {
3500 for(i=0; i<ne; ++i) {
3501 conns[i] = (int *) calloc(Elem_info[et].con_len,sizeof(int));
3502 if(conns[i] == (int *) NULL) {
3503 fprintf(stderr,"Error: allocating border conns array\n");
3504 return(Z_ERR);
3509 parent_type = (short *) calloc(ne,sizeof(short));
3510 if(parent_type == (short *) NULL) {
3511 fprintf(stderr,"Error: allocating border parent_type array\n");
3512 return(Z_ERR);
3515 parent_num = (int *) calloc(ne,sizeof(int));
3516 if(parent_num == (int *) NULL) {
3517 fprintf(stderr,"Error: allocating border parent_num array\n");
3518 return(Z_ERR);
3522 err = USERD_get_border_elements_by_type(pn,
3524 conns,
3525 parent_type,
3526 parent_num);
3527 if(err == Z_ERR) {
3528 fprintf(stderr,"Error: getting border elements\n");
3529 return(Z_ERR);
3533 /* Echo "some" info
3534 *-----------------*/
3536 /* First element of the type
3537 *--------------------------*/
3538 i = 0;
3539 fprintf(stderr," %s border element %d of %d:\n",
3540 Elem_info[et].name,i+1,ne);
3541 fprintf(stderr," Parent type: %s\n",
3542 Elem_info[parent_type[i]].name);
3543 fprintf(stderr," Parent num: %d\n",parent_num[i]);
3544 fprintf(stderr," connectivity:");
3545 for(j=0; j<Elem_info[et].con_len; ++j) {
3546 fprintf(stderr," %d",conns[i][j]);
3548 fprintf(stderr,"\n");
3550 /* Last element of the type
3551 *-------------------------*/
3552 i = ne - 1;
3553 if(i > 0) {
3554 fprintf(stderr," %s border element %d of %d:\n",
3555 Elem_info[et].name,i+1,ne);
3556 fprintf(stderr," Parent type: %s\n",
3557 Elem_info[parent_type[i]].name);
3558 fprintf(stderr," Parent num: %d\n",parent_num[i]);
3559 fprintf(stderr," connectivity:");
3560 for(j=0; j<Elem_info[et].con_len; ++j) {
3561 fprintf(stderr," %d",conns[i][j]);
3563 fprintf(stderr,"\n");
3567 /* Free the allocated memory
3568 *--------------------------*/
3569 for(i=0; i<ne; ++i) {
3570 free(conns[i]);
3572 free(conns);
3573 free(parent_type);
3574 free(parent_num);
3580 #if (defined GT_USERD_API_204)
3581 /* See if any rigid body in model
3582 *-------------------------------*/
3583 if(Any_Rigid_Body_Present) {
3585 #if (defined GT_USERD_API_207)
3586 if(USERD_rigidbody_values(pn,values) == Z_OK) {
3587 fprintf(stderr," Rigid Body values:\n");
3588 fprintf(stderr," IX = %g\n",values[0]);
3589 fprintf(stderr," IY = %g\n",values[1]);
3590 fprintf(stderr," IZ = %g\n",values[2]);
3591 fprintf(stderr," E0 = %g\n",values[3]);
3592 fprintf(stderr," E1 = %g\n",values[4]);
3593 fprintf(stderr," E2 = %g\n",values[5]);
3594 fprintf(stderr," E3 = %g\n",values[6]);
3595 fprintf(stderr," XOFF = %g\n",values[7]);
3596 fprintf(stderr," YOFF = %g\n",values[8]);
3597 fprintf(stderr," ZOFF = %g\n",values[9]);
3598 fprintf(stderr," ROT_ORDER = %g\n",values[10]);
3599 fprintf(stderr," XROT = %g\n",values[11]);
3600 fprintf(stderr," YROT = %g\n",values[12]);
3601 fprintf(stderr," ZROT = %g\n",values[13]);
3603 #else
3604 if(USERD_rigidbody_values(pn,vals) == Z_OK) {
3605 fprintf(stderr," Rigid Body values:\n");
3606 fprintf(stderr," IX = %g\n",vals[0]);
3607 fprintf(stderr," IY = %g\n",vals[1]);
3608 fprintf(stderr," IZ = %g\n",vals[2]);
3609 fprintf(stderr," E0 = %g\n",vals[3]);
3610 fprintf(stderr," E1 = %g\n",vals[4]);
3611 fprintf(stderr," E2 = %g\n",vals[5]);
3612 fprintf(stderr," E3 = %g\n",vals[6]);
3613 fprintf(stderr," XOFF = %g\n",vals[7]);
3614 fprintf(stderr," YOFF = %g\n",vals[8]);
3615 fprintf(stderr," ZOFF = %g\n",vals[9]);
3617 #endif
3619 #endif
3621 } /* end for p = 0 to Num_parts */
3623 return(Z_OK);
3627 /*----------------
3628 * gold_var_loader
3629 *----------------*/
3630 static int
3631 gold_var_loader(int var_time_step)
3633 int i, j;
3634 int err;
3635 int v, vn;
3636 int var_timeset;
3637 int p, pn;
3638 int et, e1, e2;
3639 int num_comps;
3640 int num_dims;
3641 int nsize;
3642 int comp;
3643 int bdim[3];
3644 int ne;
3645 int cell_type;
3646 float constant_val;
3647 char line1[Z_BUFL];
3648 char line2[Z_BUFL];
3649 float *values;
3650 float minv,maxv;
3651 int bd1,bd2,bd3;
3654 fprintf(stderr,"\n--------------- var_loader --------------\n");
3656 for(v=0; v<Num_vars; ++v) {
3657 vn = v + 1;
3659 if(v > 0) {
3660 fprintf(stderr,"\n");
3662 if(Varinfo[v].classify == Z_PER_NODE) {
3663 fprintf(stderr," Z_PER_NODE Variable %d:\n",vn);
3665 else {
3666 fprintf(stderr," Z_PER_ELEM Variable %d:\n",vn);
3670 if(Num_time_sets > 0) {
3671 /* Get the timeset used for the variable
3672 *---------------------------------------*/
3673 var_timeset = Varinfo[v].timeset;
3675 /* Get the number of time steps for this timeset
3676 *----------------------------------------------*/
3677 Num_time_steps = USERD_get_num_of_time_steps(var_timeset);
3678 if(Num_time_steps < 1) {
3679 fprintf(stderr," Error: Number of time steps returned: %d\n",
3680 Num_time_steps);
3681 fprintf(stderr," (Must be >0 to be okay)\n");
3682 return(Z_ERR);
3684 if(var_time_step > (Num_time_steps - 1)) {
3685 var_time_step = Num_time_steps - 1;
3688 /* Set the timeset and step - to first step by default, but
3689 * can set it at others using -vts command argument
3690 *---------------------------------------------------------*/
3691 USERD_set_time_set_and_step(var_timeset,var_time_step);
3693 fprintf(stderr," Using timeset: %d (step range is %d through %d)\n",
3694 var_timeset,0,Num_time_steps-1);
3695 fprintf(stderr," Using time step: %d\n",var_time_step);
3699 /* Constants
3700 *----------*/
3701 if(Varinfo[v].type == Z_CONSTANT) {
3703 constant_val = USERD_get_constant_val(vn,FALSE);
3704 fprintf(stderr," Constant (%s):\n",Varinfo[v].description);
3705 fprintf(stderr," value: %g\n",constant_val);
3707 if(Varinfo[v].complex) {
3708 constant_val = USERD_get_constant_val(vn,TRUE);
3709 fprintf(stderr," value (imag): %g\n",constant_val);
3713 /* Scalars, Vectors, Tensors
3714 *--------------------------*/
3715 else {
3717 /* Get the var description line
3718 *-----------------------------*/
3719 err = USERD_get_descrip_lines(Z_VARI,vn,FALSE,line1,line2);
3720 if(err == Z_OK) {
3721 fprintf(stderr," Desc line: %s\n",line1);
3723 else {
3724 fprintf(stderr,"Error: getting var description line\n");
3725 return(Z_ERR);
3728 if(Varinfo[v].complex) {
3729 err = USERD_get_descrip_lines(Z_VARI,vn,TRUE,line1,line2);
3730 if(err == Z_OK) {
3731 fprintf(stderr," Desc line (imag): %s\n",line1);
3733 else {
3734 fprintf(stderr,"Error: getting var description line (imag)\n");
3735 return(Z_ERR);
3740 /* Get the values by component
3741 *-----------------------------*/
3742 if(Varinfo[v].type == Z_SCALAR) {
3743 num_comps = 1;
3745 else if(Varinfo[v].type == Z_VECTOR) {
3746 num_comps = 3;
3748 else if(Varinfo[v].type == Z_TENSOR) {
3749 num_comps = 6;
3751 else if(Varinfo[v].type == Z_TENSOR9) {
3752 num_comps = 9;
3756 /* Per_Node
3757 *---------*/
3758 if(Varinfo[v].classify == Z_PER_NODE) {
3760 for(p=0; p<Num_parts; ++p) {
3761 pn = p + 1;
3763 if(Pbuild[p].type == Z_UNSTRUCTURED) {
3764 nsize = Pbuild[p].nn;
3766 else {
3767 for(comp=0; comp<3; ++comp) {
3768 if(Pbuild[p].ne[comp] < 1) {
3769 bdim[comp] = 1;
3771 else {
3773 if(Doing_Structured_Cinching) {
3774 bdim[comp] = Pbuild[p].ne[comp];
3776 /* even */
3777 if((bdim[comp] % 2) == 0) {
3778 bdim[comp] = (bdim[comp]/2) + 1;
3780 /* odd */
3781 else {
3782 bdim[comp] = ((bdim[comp]-1)/2) + 1;
3786 else {
3787 bdim[comp] = Pbuild[p].ne[comp];
3791 nsize = bdim[0] * bdim[1] * bdim[2];
3793 /* For structured cinching, send in one less on each end and stride of 2
3794 *----------------------------------------------------------------------*/
3795 if(Doing_Structured_Cinching) {
3796 err = USERD_set_block_range_and_stride(pn,
3797 0, Pbuild[p].ne[0]-1, 2,
3798 0, Pbuild[p].ne[1]-1, 2,
3799 0, Pbuild[p].ne[2]-1, 2);
3804 fprintf(stderr," For part %d, with %d nodes:\n",pn,nsize);
3806 if(nsize > 0) {
3807 values = (float *) calloc((nsize+1),sizeof(float));
3808 if(values == (float *) NULL) {
3809 fprintf(stderr,"Error: alocating variable values\n");
3810 return(Z_ERR);
3813 for(comp=0; comp<num_comps; ++comp) {
3815 err = USERD_get_var_by_component(vn,
3817 Varinfo[v].type,
3819 FALSE,
3820 comp,
3821 values);
3822 if(err == Z_UNDEF) {
3823 fprintf(stderr," Variable not defined on this part\n");
3827 /* For the component, show 1st node, last node, min, max values
3828 *-------------------------------------------------------------*/
3829 minv = maxv = values[1];
3830 for(i=2; i<=nsize; ++i) {
3831 if(values[i] < minv) {
3832 minv = values[i];
3834 if(values[i] > maxv) {
3835 maxv = values[i];
3839 fprintf(stderr," For component %d: \n",comp);
3840 fprintf(stderr," node %10d value: %g\n",1,values[1]);
3841 fprintf(stderr," node %10d value: %g\n",nsize,values[nsize]);
3842 fprintf(stderr," min value: %g\n",minv);
3843 fprintf(stderr," max value: %g\n",maxv);
3845 if(Varinfo[v].complex) {
3846 err = USERD_get_var_by_component(vn,
3848 Varinfo[v].type,
3850 FALSE,
3851 comp,
3852 values);
3853 if(err == Z_UNDEF) {
3854 fprintf(stderr," Variable not defined on this part\n");
3857 /* For the component, show 1st node, last node, min, max values
3858 *-------------------------------------------------------------*/
3859 minv = maxv = values[1];
3860 for(i=2; i<=nsize; ++i) {
3861 if(values[i] < minv) {
3862 minv = values[i];
3864 if(values[i] > maxv) {
3865 maxv = values[i];
3869 fprintf(stderr," For component %d (imag): \n",comp);
3870 fprintf(stderr," node %10d value: %g\n",1,values[1]);
3871 fprintf(stderr," node %10d value: %g\n",nsize,values[nsize]);
3872 fprintf(stderr," min value: %g\n",minv);
3873 fprintf(stderr," max value: %g\n",maxv);
3876 free(values);
3881 /* Per_Elem
3882 *---------*/
3883 else {
3884 for(p=0; p<Num_parts; ++p) {
3885 pn = p + 1;
3887 if(Pbuild[p].type != Z_UNSTRUCTURED) {
3889 for(comp=0; comp<3; ++comp) {
3890 if(Pbuild[p].ne[comp] < 1) {
3891 bdim[comp] = 1;
3893 else {
3894 if(Doing_Structured_Cinching) {
3895 bdim[comp] = Pbuild[p].ne[comp];
3897 /* even */
3898 if((bdim[comp] % 2) == 0) {
3899 bdim[comp] = (bdim[comp]/2) + 1;
3901 /* odd */
3902 else {
3903 bdim[comp] = ((bdim[comp]-1)/2) + 1;
3907 else {
3908 bdim[comp] = Pbuild[p].ne[comp];
3913 bd1 = bdim[0]-1;
3914 if(bd1 < 1) {
3915 bd1 = 1;
3917 bd2 = bdim[1]-1;
3918 if(bd2 < 1) {
3919 bd2 = 1;
3921 bd3 = bdim[2]-1;
3922 if(bd3 < 1) {
3923 bd3 = 1;
3925 nsize = bd1 * bd2 * bd3;
3928 /* Determine cell type
3929 *--------------------*/
3930 num_dims = 3;
3931 for(i=0; i<3; ++i) {
3932 if(bdim[i] == 1) {
3933 --num_dims;
3936 if(num_dims == 3) {
3937 cell_type = Z_HEX08;
3939 else if(num_dims == 2) {
3940 cell_type = Z_QUA04;
3942 else {
3943 cell_type = Z_BAR02;
3947 if(Pbuild[p].type == Z_UNSTRUCTURED) {
3948 e1 = 0;
3949 e2 = Z_MAXTYPE-1;
3951 else {
3952 e1 = e2 = cell_type;
3955 /* For structured cinching, send in one less on each end and stride of 2
3956 *----------------------------------------------------------------------*/
3957 if(Doing_Structured_Cinching) {
3958 err = USERD_set_block_range_and_stride(pn,
3959 0, Pbuild[p].ne[0]-1, 2,
3960 0, Pbuild[p].ne[1]-1, 2,
3961 0, Pbuild[p].ne[2]-1, 2);
3965 for(et=e1; et<=e2; ++et) {
3967 if(Pbuild[p].type == Z_UNSTRUCTURED) {
3968 nsize = Pbuild[p].ne[et];
3971 if(nsize > 0) {
3973 fprintf(stderr," For part %d, with %d elems of type %s:\n",
3974 pn,nsize,Elem_info[et].name);
3977 values = (float *) calloc((nsize+1),sizeof(float));
3978 if(values == (float *) NULL) {
3979 fprintf(stderr,"Error: alocating variable values\n");
3980 return(Z_ERR);
3983 for(comp=0; comp<num_comps; ++comp) {
3985 err = USERD_get_var_by_component(vn,
3987 Varinfo[v].type,
3989 FALSE,
3990 comp,
3991 values);
3992 if(err == Z_UNDEF) {
3993 fprintf(stderr," Variable not defined on this part\n");
3996 /* For the component, show 1st elem, last elem, min, max values
3997 *-------------------------------------------------------------*/
3998 minv = maxv = values[1];
3999 for(i=2; i<=nsize; ++i) {
4000 if(values[i] < minv) {
4001 minv = values[i];
4003 if(values[i] > maxv) {
4004 maxv = values[i];
4008 fprintf(stderr," For component %d: \n",comp);
4009 fprintf(stderr," elem %10d value: %g\n",1,values[1]);
4010 fprintf(stderr," elem %10d value: %g\n",nsize,values[nsize]);
4011 fprintf(stderr," min value: %g\n",minv);
4012 fprintf(stderr," max value: %g\n",maxv);
4014 if(Varinfo[v].complex) {
4015 err = USERD_get_var_by_component(vn,
4017 Varinfo[v].type,
4019 FALSE,
4020 comp,
4021 values);
4022 if(err == Z_UNDEF) {
4023 fprintf(stderr," Variable not defined on this part\n");
4026 /* For the component, show 1st elem, last elem, min, max values
4027 *-------------------------------------------------------------*/
4028 minv = maxv = values[1];
4029 for(i=2; i<=nsize; ++i) {
4030 if(values[i] < minv) {
4031 minv = values[i];
4033 if(values[i] > maxv) {
4034 maxv = values[i];
4038 fprintf(stderr," For component %d (imag): \n",comp);
4039 fprintf(stderr," elem %10d value: %g\n",1,values[1]);
4040 fprintf(stderr," elem %10d value: %g\n",nsize,values[nsize]);
4041 fprintf(stderr," min value: %g\n",minv);
4042 fprintf(stderr," max value: %g\n",maxv);
4046 free(values);
4054 return(Z_OK);
4057 #else
4059 /*-------------
4060 * part_builder
4061 *-------------*/
4062 static int
4063 part_builder(int geom_time_step)
4065 int i, j;
4066 int err;
4067 int p, pn;
4068 int et, ne;
4069 int *elemids[Z_MAXTYPE];
4070 int **conns[Z_MAXTYPE];
4071 int nn;
4072 int comp;
4073 int bdim[3];
4074 int ib[5];
4075 int num_dims;
4076 int cell_type;
4077 float mm[6];
4078 float **coords;
4079 int *nodeids;
4080 int *iblanking;
4081 CRD *crds;
4082 int bd1,bd2,bd3;
4085 fprintf(stderr,"\n------------- part_builder --------------\n");
4088 if(Num_time_steps > 1) {
4089 if(geom_time_step > (Num_time_steps - 1)) {
4090 geom_time_step = Num_time_steps - 1;
4093 /* Set the time step - to first step by default, but
4094 * can set it at others using -gts command argument
4095 *---------------------------------------------------*/
4096 USERD_set_time_step(geom_time_step);
4098 fprintf(stderr," Using time step: %d (where range is %d through %d\n",
4099 geom_time_step,0,Num_time_steps-1);
4103 /* Get the global coords
4104 *----------------------*/
4105 nn = USERD_get_number_of_global_nodes();
4107 if(nn > 0) {
4109 crds = (CRD *) calloc(nn,sizeof(CRD));
4110 if(crds == (CRD *) NULL) {
4111 fprintf(stderr,"Error: allocating crds array\n");
4112 return(Z_ERR);
4115 if(Node_labels) {
4116 nodeids = (int *) calloc(nn,sizeof(int));
4117 if(nodeids == (int *) NULL) {
4118 fprintf(stderr,"Error: allocating nodeids array\n");
4119 return(Z_ERR);
4124 err = USERD_get_global_coords(crds);
4125 if(err == Z_ERR) {
4126 fprintf(stderr,"Error: getting unstructured coords\n");
4127 return(Z_ERR);
4130 if(Node_labels) {
4131 err = USERD_get_global_node_ids(nodeids);
4132 if(err == Z_ERR) {
4133 fprintf(stderr,"Error: getting nodeids\n");
4134 return(Z_ERR);
4138 /* Echo "some" info
4139 *-----------------*/
4141 /* First node
4142 *-----------*/
4143 i = 0;
4144 fprintf(stderr," Node %d of %d:\n",i+1,nn);
4145 if(Node_labels) {
4146 fprintf(stderr," id: %d\n",nodeids[i]);
4148 fprintf(stderr," x y z coordinates: %g %g %g\n",
4149 crds[i].xyz[0], crds[i].xyz[1], crds[i].xyz[2]);
4150 mm[0] = mm[1] = crds[i].xyz[0];
4151 mm[2] = mm[3] = crds[i].xyz[1];
4152 mm[4] = mm[5] = crds[i].xyz[2];
4155 /* Last node
4156 *----------*/
4157 i = nn-1;
4158 if(i > 0) {
4159 fprintf(stderr," Node %d of %d:\n",i+1,nn);
4160 if(Node_labels) {
4161 fprintf(stderr," id: %d\n",nodeids[i]);
4163 fprintf(stderr," x y z coordinates: %g %g %g\n",
4164 crds[i].xyz[0], crds[i].xyz[1], crds[i].xyz[2]);
4167 /* Min and max coordinate values
4168 *------------------------------*/
4169 for(i=1; i<nn; ++i) {
4170 if(crds[i].xyz[0] < mm[0]) {
4171 mm[0] = crds[i].xyz[0];
4173 if(crds[i].xyz[0] > mm[1]) {
4174 mm[1] = crds[i].xyz[0];
4176 if(crds[i].xyz[1] < mm[2]) {
4177 mm[2] = crds[i].xyz[1];
4179 if(crds[i].xyz[1] > mm[3]) {
4180 mm[3] = crds[i].xyz[1];
4182 if(crds[i].xyz[2] < mm[4]) {
4183 mm[4] = crds[i].xyz[2];
4185 if(crds[i].xyz[2] > mm[5]) {
4186 mm[5] = crds[i].xyz[2];
4190 fprintf(stderr," Global coordinate ranges:\n");
4191 fprintf(stderr," min x: %g\n",mm[0]);
4192 fprintf(stderr," max x: %g\n",mm[1]);
4193 fprintf(stderr," min y: %g\n",mm[2]);
4194 fprintf(stderr," max y: %g\n",mm[3]);
4195 fprintf(stderr," min z: %g\n",mm[4]);
4196 fprintf(stderr," max z: %g\n",mm[5]);
4199 /* Free the allocated memory
4200 *--------------------------*/
4201 free(crds);
4202 if(Node_labels) {
4203 free(nodeids);
4209 for(p=0; p<Num_parts; ++p) {
4210 pn = p+1;
4212 fprintf(stderr,"\n");
4213 fprintf(stderr," Part %d:\n",pn);
4215 /*-----------------------
4216 * For unstructured parts
4217 *-----------------------*/
4218 if(Pbuild[p].type == Z_UNSTRUCTURED) {
4220 for(et=0; et<Z_MAXTYPE; ++et) {
4221 ne = Pbuild[p].ne[et];
4223 if(ne > 0) {
4225 conns[et] = (int **) calloc(ne,sizeof(int *));
4226 if(conns[et] == (int **) NULL) {
4227 fprintf(stderr,"Error: allocating conns array\n");
4228 return(Z_ERR);
4230 else {
4231 for(i=0; i<ne; ++i) {
4232 conns[et][i] = (int *) calloc(Elem_info[et].con_len,sizeof(int));
4233 if(conns[et][i] == (int *) NULL) {
4234 fprintf(stderr,"Error: allocating conns array\n");
4235 return(Z_ERR);
4240 if(Element_labels) {
4241 elemids[et] = (int *) calloc(ne,sizeof(int));
4242 if(elemids[et] == (int *) NULL) {
4243 fprintf(stderr,"Error: allocating elemids array\n");
4244 return(Z_ERR);
4250 /* Get the elements
4251 *-----------------*/
4252 err = USERD_get_element_connectivities_for_part(pn,conns);
4253 if(err == Z_ERR) {
4254 fprintf(stderr,"Error: getting element connectivities\n");
4255 return(Z_ERR);
4258 /* Get the element ids - if any
4259 *-----------------------------*/
4260 if(Element_labels) {
4261 err = USERD_get_element_ids_for_part(pn,elemids);
4262 if(err == Z_ERR) {
4263 fprintf(stderr,"Error: getting element ids\n");
4264 return(Z_ERR);
4268 /* Echo "some" info
4269 *-----------------*/
4270 for(et=0; et<Z_MAXTYPE; ++et) {
4271 ne = Pbuild[p].ne[et];
4273 if(ne > 0) {
4275 /* First element of the type
4276 *--------------------------*/
4277 i = 0;
4278 fprintf(stderr," %s Element %d of %d:\n",Elem_info[et].name,i+1,ne);
4279 if(Element_labels) {
4280 fprintf(stderr," id: %d\n",elemids[et][i]);
4282 fprintf(stderr," connectivity:");
4283 for(j=0; j<Elem_info[et].con_len; ++j) {
4284 fprintf(stderr," %d",conns[et][i][j]);
4286 fprintf(stderr,"\n");
4288 /* Last element of the type
4289 *-------------------------*/
4290 i = ne - 1;
4291 if(i > 0) {
4292 fprintf(stderr," %s Element %d of %d:\n",Elem_info[et].name,i+1,ne);
4293 if(Element_labels) {
4294 fprintf(stderr," id: %d\n",elemids[et][i]);
4296 fprintf(stderr," connectivity:");
4297 for(j=0; j<Elem_info[et].con_len; ++j) {
4298 fprintf(stderr," %d",conns[et][i][j]);
4300 fprintf(stderr,"\n");
4305 /* Free the allocated memory
4306 *--------------------------*/
4307 for(et=0; et<Z_MAXTYPE; ++et) {
4308 ne = Pbuild[p].ne[et];
4310 if(ne > 0) {
4311 for(i=0; i<ne; ++i) {
4312 free(conns[et][i]);
4314 free(conns[et]);
4316 if(Element_labels) {
4317 free(elemids[et]);
4324 /*---------------------
4325 * For structured parts
4326 *---------------------*/
4327 else {
4329 /* Get the block coords
4330 *---------------------*/
4331 for(comp=0; comp<3; ++comp) {
4332 if(Pbuild[p].ne[comp] < 1) {
4333 bdim[comp] = 1;
4335 else {
4336 bdim[comp] = Pbuild[p].ne[comp];
4339 nn = bdim[0] * bdim[1] * bdim[2];
4341 bd1 = bdim[0]-1;
4342 if(bd1 < 1) {
4343 bd1 = 1;
4345 bd2 = bdim[1]-1;
4346 if(bd2 < 1) {
4347 bd2 = 1;
4349 bd3 = bdim[2]-1;
4350 if(bd3 < 1) {
4351 bd3 = 1;
4353 ne = bd1 * bd2 * bd3;
4356 /* Determine cell type
4357 *--------------------*/
4358 num_dims = 3;
4359 for(i=0; i<3; ++i) {
4360 if(bdim[i] == 1) {
4361 --num_dims;
4364 if(num_dims == 3) {
4365 cell_type = Z_HEX08;
4367 else if(num_dims == 2) {
4368 cell_type = Z_QUA04;
4370 else {
4371 cell_type = Z_BAR02;
4374 coords = (float **) calloc(num_dims,sizeof(float *));
4375 if(coords == (float **) NULL) {
4376 fprintf(stderr,"Error: allocating coords array\n");
4377 return(Z_ERR);
4379 else {
4380 for(i=0; i<num_dims; ++i) {
4381 coords[i] = (float *) calloc(nn,sizeof(float));
4382 if(coords[i] == (float *) NULL) {
4383 fprintf(stderr,"Error: allocating coords array\n");
4384 return(Z_ERR);
4389 /* Get the coords
4390 *---------------*/
4391 for(comp=0; comp<num_dims; ++comp) {
4392 err = USERD_get_block_coords_by_component(pn,comp,coords[comp]);
4393 if(err == Z_ERR) {
4394 fprintf(stderr,"Error: getting block coords\n");
4395 return(Z_ERR);
4400 /* Echo "some" info
4401 *-----------------*/
4403 /* First node
4404 *-----------*/
4405 if(nn > 0) {
4406 i = 0;
4407 fprintf(stderr," Node %d of %d:\n",i+1,nn);
4409 if(num_dims == 3) {
4410 fprintf(stderr," x y z coordinates: %g %g %g\n",
4411 coords[0][i], coords[1][i], coords[2][i]);
4412 mm[0] = mm[1] = coords[0][i];
4413 mm[2] = mm[3] = coords[1][i];
4414 mm[4] = mm[5] = coords[2][i];
4416 else if(num_dims == 2) {
4417 fprintf(stderr," x y coordinates: %g %g\n",
4418 coords[0][i], coords[1][i]);
4419 mm[0] = mm[1] = coords[0][i];
4420 mm[2] = mm[3] = coords[1][i];
4422 else {
4423 fprintf(stderr," x coordinates: %g\n",
4424 coords[0][i]);
4425 mm[0] = mm[1] = coords[0][i];
4429 /* Last node
4430 *----------*/
4431 i = nn-1;
4432 if(i > 1) {
4433 fprintf(stderr," Node %d of %d:\n",i+1,nn);
4435 if(num_dims == 3) {
4436 fprintf(stderr," x y z coordinates: %g %g %g\n",
4437 coords[0][i], coords[1][i], coords[2][i]);
4439 else if(num_dims == 2) {
4440 fprintf(stderr," x y coordinates: %g %g\n",
4441 coords[0][i], coords[1][i]);
4443 else {
4444 fprintf(stderr," x coordinates: %g\n",
4445 coords[0][i]);
4450 /* Min and max coordinate values
4451 *------------------------------*/
4452 for(i=2; i<=nn; ++i) {
4453 if(coords[0][i] < mm[0]) {
4454 mm[0] = coords[0][i];
4456 if(coords[0][i] > mm[1]) {
4457 mm[1] = coords[0][i];
4459 if(num_dims > 1) {
4460 if(coords[1][i] < mm[2]) {
4461 mm[2] = coords[1][i];
4463 if(coords[1][i] > mm[3]) {
4464 mm[3] = coords[1][i];
4467 if(num_dims > 2) {
4468 if(coords[2][i] < mm[4]) {
4469 mm[4] = coords[2][i];
4471 if(coords[2][i] > mm[5]) {
4472 mm[5] = coords[2][i];
4477 fprintf(stderr," Coordinate ranges:\n");
4478 fprintf(stderr," min x: %g\n",mm[0]);
4479 fprintf(stderr," max x: %g\n",mm[1]);
4480 if(num_dims > 1) {
4481 fprintf(stderr," min y: %g\n",mm[2]);
4482 fprintf(stderr," max y: %g\n",mm[3]);
4484 if(num_dims > 2) {
4485 fprintf(stderr," min z: %g\n",mm[4]);
4486 fprintf(stderr," max z: %g\n",mm[5]);
4489 /* Free the allocated memory - so far
4490 *-----------------------------------*/
4491 for(i=0; i<num_dims; ++i) {
4492 free(coords[i]);
4494 free(coords);
4497 /* Get the block iblanking - if any
4498 *---------------------------------*/
4499 if(Pbuild[p].type == Z_IBLANKED) {
4501 iblanking = (int *) calloc(nn,sizeof(int));
4502 if(iblanking == (int *) NULL) {
4503 fprintf(stderr,"Error: allocating iblanking array\n");
4504 return(Z_ERR);
4507 err = USERD_get_block_iblanking(pn,iblanking);
4508 if(err == Z_ERR) {
4509 fprintf(stderr,"Error: getting block iblanking\n");
4510 return(Z_ERR);
4513 /* Echo "some" info
4514 *-----------------*/
4515 ib[Z_EXT] = 0;
4516 ib[Z_INT] = 0;
4517 ib[Z_BND] = 0;
4518 ib[Z_INTBND] = 0;
4519 ib[Z_SYM] = 0;
4521 for(i=0; i<nn; ++i) {
4522 ++ib[iblanking[i]];
4525 fprintf(stderr," Iblanking breakdown:\n");
4526 fprintf(stderr," Number of Z_EXT: %d\n",ib[Z_EXT]);
4527 fprintf(stderr," Number of Z_INT: %d\n",ib[Z_INT]);
4528 fprintf(stderr," Number of Z_BND: %d\n",ib[Z_BND]);
4529 fprintf(stderr," Number of Z_INTBND: %d\n",ib[Z_INTBND]);
4530 fprintf(stderr," Number of Z_SYM: %d\n",ib[Z_SYM]);
4532 free(iblanking);
4537 return(Z_OK);
4541 /*-----------
4542 * var_loader
4543 *-----------*/
4544 static int
4545 var_loader(int var_time_step)
4547 int i, j, k;
4548 int err;
4549 int v, vn;
4550 int var_timeset;
4551 int p, pn;
4552 int et, e1, e2;
4553 int num_comps;
4554 int num_dims;
4555 int nsize;
4556 int comp;
4557 int bdim[3];
4558 int ne;
4559 int cell_type;
4560 float constant_val;
4561 char line1[Z_BUFL];
4562 char line2[Z_BUFL];
4563 float *values;
4564 float *tvalues;
4565 float minv[3],maxv[3];
4566 int bd1,bd2,bd3;
4569 fprintf(stderr,"\n--------------- var_loader --------------\n");
4571 if(Num_time_steps > 1 && v == 0) {
4572 if(var_time_step > (Num_time_steps - 1)) {
4573 var_time_step = Num_time_steps - 1;
4576 /* Set the time step - to first step by default, but
4577 * can set it at others using -vts command argument
4578 *---------------------------------------------------------*/
4579 USERD_set_time_step(var_time_step);
4581 fprintf(stderr," Using time step: %d (where range is %d through %d)\n\n",
4582 var_time_step,0,Num_time_steps-1);
4585 for(v=0; v<Num_vars; ++v) {
4586 vn = v + 1;
4588 if(v > 0) {
4589 fprintf(stderr,"\n");
4591 if(Varinfo[v].classify == Z_PER_NODE) {
4592 fprintf(stderr," Z_PER_NODE Variable %d:\n",vn);
4594 else {
4595 fprintf(stderr," Z_PER_ELEM Variable %d:\n",vn);
4598 /* Constants
4599 *----------*/
4600 if(Varinfo[v].type == Z_CONSTANT) {
4602 constant_val = USERD_get_constant_value(vn);
4603 fprintf(stderr," Constant (%s):\n",Varinfo[v].description);
4604 fprintf(stderr," value: %g\n",constant_val);
4608 /* Scalars, Vectors, Tensors
4609 *--------------------------*/
4610 else {
4612 /* Get the var description line
4613 *-----------------------------*/
4614 err = USERD_get_description_lines(Z_VARI,vn,line1,line2);
4615 if(err == Z_OK) {
4616 fprintf(stderr," Desc line: %s\n",line1);
4618 else {
4619 fprintf(stderr,"Error: getting var description line\n");
4620 return(Z_ERR);
4624 /* Get the values by component
4625 *-----------------------------*/
4626 if(Varinfo[v].type == Z_SCALAR) {
4627 num_comps = 1;
4629 else if(Varinfo[v].type == Z_VECTOR) {
4630 num_comps = 3;
4632 else if(Varinfo[v].type == Z_TENSOR) {
4633 num_comps = 6;
4635 else if(Varinfo[v].type == Z_TENSOR9) {
4636 num_comps = 9;
4640 /* Per_Node
4641 *---------*/
4642 if(Varinfo[v].classify == Z_PER_NODE) {
4644 for(p=0; p<Num_parts; ++p) {
4645 pn = p + 1;
4647 if(Pbuild[p].type == Z_UNSTRUCTURED) {
4648 nsize = Pbuild[p].nn;
4650 else {
4651 for(comp=0; comp<3; ++comp) {
4652 if(Pbuild[p].ne[comp] < 1) {
4653 bdim[comp] = 1;
4655 else {
4656 bdim[comp] = Pbuild[p].ne[comp];
4659 nsize = bdim[0] * bdim[1] * bdim[2];
4663 fprintf(stderr," For part %d, with %d nodes:\n",pn,nsize);
4665 if(nsize > 0) {
4666 values = (float *) calloc((num_comps * nsize),sizeof(float));
4667 if(values == (float *) NULL) {
4668 fprintf(stderr,"Error: alocating variable values\n");
4669 return(Z_ERR);
4672 if(num_comps == 1) {
4674 if(Pbuild[p].type == Z_UNSTRUCTURED) {
4675 err = USERD_get_scalar_values(vn,
4678 values);
4679 if(err == Z_ERR) {
4680 fprintf(stderr,"Error: getting scalar values\n");
4681 return(Z_ERR);
4684 else {
4685 err = USERD_get_block_scalar_values(pn,
4687 values);
4688 if(err == Z_ERR) {
4689 fprintf(stderr,"Error: getting block scalar values\n");
4690 return(Z_ERR);
4694 /* For the component, show 1st node, last node, min, max values
4695 *-------------------------------------------------------------*/
4696 minv[0] = maxv[0] = values[0];
4697 for(i=0; i<nsize; ++i) {
4698 if(values[i] < minv[0]) {
4699 minv[0] = values[i];
4701 if(values[i] > maxv[0]) {
4702 maxv[0] = values[i];
4706 fprintf(stderr," node %10d value: %g\n",1,values[0]);
4707 fprintf(stderr," node %10d value: %g\n",nsize,values[nsize-1]);
4708 fprintf(stderr," min value: %g\n",minv[0]);
4709 fprintf(stderr," max value: %g\n",maxv[0]);
4713 else if(num_comps == 3) {
4715 if(Pbuild[p].type == Z_UNSTRUCTURED) {
4716 err = USERD_get_vector_values(vn,
4719 values);
4720 if(err == Z_ERR) {
4721 fprintf(stderr,"Error: getting vector values\n");
4722 return(Z_ERR);
4725 else {
4727 tvalues = (float *) calloc(nsize,sizeof(float));
4728 if(tvalues == (float *) NULL) {
4729 fprintf(stderr,"Error: alocating tvalues array\n");
4730 return(Z_ERR);
4733 for(i=0; i<3; ++i) {
4734 err = USERD_get_block_vector_values_by_component(pn,
4737 tvalues);
4738 if(err == Z_ERR) {
4739 fprintf(stderr,"Error: getting vector values\n");
4740 return(Z_ERR);
4742 for(j=0; j<nsize; ++j) {
4743 k = j*3 + i;
4744 values[k] = tvalues[j];
4747 free(tvalues);
4750 /* For the component, show 1st node, last node, min, max values
4751 *-------------------------------------------------------------*/
4752 minv[0] = maxv[0] = values[0];
4753 minv[1] = maxv[1] = values[1];
4754 minv[2] = maxv[2] = values[2];
4755 for(i=0; i<nsize; ++i) {
4756 j = i*3;
4757 for(k=0; k<3; ++k) {
4758 if(values[j+k] < minv[k]) {
4759 minv[k] = values[j+k];
4761 if(values[j+k] > maxv[k]) {
4762 maxv[k] = values[j+k];
4767 fprintf(stderr," node %10d values: %g %g %g\n",1,
4768 values[0],values[1],values[2]);
4769 fprintf(stderr," node %10d values: %g %g %g\n",nsize,
4770 values[3*nsize-3],values[3*nsize-2],values[3*nsize-1]);
4771 fprintf(stderr," min values: %g %g %g\n",
4772 minv[0],minv[1],minv[2]);
4773 fprintf(stderr," max values: %g %g %g\n",
4774 maxv[0],maxv[1],maxv[2]);
4777 free(values);
4782 /* Per_Elem
4783 *---------*/
4784 else {
4785 for(p=0; p<Num_parts; ++p) {
4786 pn = p + 1;
4788 if(Pbuild[p].type != Z_UNSTRUCTURED) {
4790 for(comp=0; comp<3; ++comp) {
4791 if(Pbuild[p].ne[comp] < 1) {
4792 bdim[comp] = 1;
4794 else {
4795 bdim[comp] = Pbuild[p].ne[comp];
4798 bd1 = bdim[0]-1;
4799 if(bd1 < 1) {
4800 bd1 = 1;
4802 bd2 = bdim[1]-1;
4803 if(bd2 < 1) {
4804 bd2 = 1;
4806 bd3 = bdim[2]-1;
4807 if(bd3 < 1) {
4808 bd3 = 1;
4810 nsize = bd1 * bd2 * bd3;
4813 /* Determine cell type
4814 *--------------------*/
4815 num_dims = 3;
4816 for(i=0; i<3; ++i) {
4817 if(bdim[i] == 1) {
4818 --num_dims;
4821 if(num_dims == 3) {
4822 cell_type = Z_HEX08;
4824 else if(num_dims == 2) {
4825 cell_type = Z_QUA04;
4827 else {
4828 cell_type = Z_BAR02;
4832 if(Pbuild[p].type == Z_UNSTRUCTURED) {
4833 e1 = 0;
4834 e2 = Z_MAXTYPE-1;
4836 else {
4837 e1 = e2 = cell_type;
4840 for(et=e1; et<=e2; ++et) {
4842 if(Pbuild[p].type == Z_UNSTRUCTURED) {
4843 nsize = Pbuild[p].ne[et];
4846 if(nsize > 0) {
4848 fprintf(stderr," For part %d, with %d elems of type %s:\n",
4849 pn,nsize,Elem_info[et].name);
4851 values = (float *) calloc((num_comps * nsize),sizeof(float));
4852 if(values == (float *) NULL) {
4853 fprintf(stderr,"Error: alocating variable values\n");
4854 return(Z_ERR);
4857 if(num_comps == 1) {
4858 if(Pbuild[p].type == Z_UNSTRUCTURED) {
4859 err = USERD_get_scalar_values(vn,
4862 values);
4863 if(err == Z_ERR) {
4864 fprintf(stderr,"Error: getting scalar values\n");
4865 return(Z_ERR);
4868 else {
4869 err = USERD_get_block_scalar_values(pn,
4871 values);
4872 if(err == Z_ERR) {
4873 fprintf(stderr,"Error: getting block scalar values\n");
4874 return(Z_ERR);
4878 /* For the component, show 1st node, last node, min, max values
4879 *-------------------------------------------------------------*/
4880 minv[0] = maxv[0] = values[0];
4881 for(i=1; i<nsize; ++i) {
4882 if(values[i] < minv[0]) {
4883 minv[0] = values[i];
4885 if(values[i] > maxv[0]) {
4886 maxv[0] = values[i];
4890 fprintf(stderr," elem %10d value: %g\n",1,values[0]);
4891 fprintf(stderr," elem %10d value: %g\n",nsize,values[nsize-1]);
4892 fprintf(stderr," min value: %g\n",minv[0]);
4893 fprintf(stderr," max value: %g\n",maxv[0]);
4897 else if(num_comps == 3) {
4899 if(Pbuild[p].type == Z_UNSTRUCTURED) {
4900 err = USERD_get_vector_values(vn,
4903 values);
4904 if(err == Z_ERR) {
4905 fprintf(stderr,"Error: getting vector values\n");
4906 return(Z_ERR);
4909 else {
4911 tvalues = (float *) calloc(nsize,sizeof(float));
4912 if(tvalues == (float *) NULL) {
4913 fprintf(stderr,"Error: alocating tvalues array\n");
4914 return(Z_ERR);
4917 for(i=0; i<3; ++i) {
4918 err = USERD_get_block_vector_values_by_component(pn,
4921 tvalues);
4922 if(err == Z_ERR) {
4923 fprintf(stderr,"Error: getting vector values\n");
4924 return(Z_ERR);
4926 for(j=0; j<nsize; ++j) {
4927 k = j*3 + i;
4928 values[k] = tvalues[j];
4931 free(tvalues);
4934 /* For the component, show 1st node, last node, min, max values
4935 *-------------------------------------------------------------*/
4936 minv[0] = maxv[0] = values[0];
4937 minv[1] = maxv[1] = values[1];
4938 minv[2] = maxv[2] = values[2];
4939 for(i=1; i<=nsize; ++i) {
4940 j = i*3;
4941 for(k=0; k<3; ++k) {
4942 if(values[j+k] < minv[k]) {
4943 minv[k] = values[j+k];
4945 if(values[j+k] > maxv[k]) {
4946 maxv[k] = values[j+k];
4951 fprintf(stderr," elem %10d values: %g %g %g\n",1,
4952 values[0],values[1],values[2]);
4953 fprintf(stderr," elem %10d values: %g %g %g\n",nsize,
4954 values[3*nsize-3],values[3*nsize-2],values[3*nsize-1]);
4955 fprintf(stderr," min values: %g %g %g\n",
4956 minv[0],minv[1],minv[2]);
4957 fprintf(stderr," max values: %g %g %g\n",
4958 maxv[0],maxv[1],maxv[2]);
4961 free(values);
4969 return(Z_OK);
4972 #endif
4975 #if (defined GT_USERD_API_202)
4978 /*---------------
4979 * materials_info
4980 *---------------*/
4981 static int
4982 materials_info( void )
4984 int i,j;
4985 int err;
4986 int *num_materials;
4987 int *msids;
4988 char **msname;
4989 int *mids;
4990 char **mdesc;
4993 fprintf(stderr,"\n------------- materials info --------------\n");
4995 /* Get the number of variables
4996 *----------------------------*/
4997 Num_materials_sets = USERD_get_number_of_material_sets();
4998 if(Num_materials_sets < 0) {
4999 fprintf(stderr,"Error: getting the number of material sets\n");
5000 return(Z_ERR);
5002 else {
5003 if(Num_materials_sets == 0) {
5004 fprintf(stderr," No materials sets in the model\n");
5005 return (Z_OK);
5007 else if(Num_materials_sets > 1) {
5008 fprintf(stderr," Number of materials sets: %d\n",Num_materials_sets);
5009 fprintf(stderr," Currently, EnSight 7.6 only supports 1 material set\n");
5010 return(Z_ERR);
5012 else {
5013 fprintf(stderr," Number of materials sets: %d\n",Num_materials_sets);
5017 /* Get the material set index list and names
5018 *------------------------------------------*/
5019 msids = (int *) calloc(Num_materials_sets,sizeof(int));
5020 if(msids == (int *)NULL) {
5021 fprintf(stderr," Problems allocating for material set ids\n");
5022 return(Z_ERR);
5025 num_materials = (int *) calloc(Num_materials_sets,sizeof(int));
5026 if(num_materials == (int *)NULL) {
5027 fprintf(stderr," Problems allocating for material set num materials\n");
5028 return(Z_ERR);
5031 msname = (char **) calloc(Num_materials_sets,sizeof(char *));
5032 if(msname == (char **)NULL) {
5033 fprintf(stderr," Problems allocating for material set names\n");
5034 return(Z_ERR);
5036 else {
5037 for(i=0; i<Num_materials_sets; ++i) {
5038 msname[i] = (char *) calloc(Z_BUFL,sizeof(char));
5039 if(msname[i] == (char *)NULL) {
5040 fprintf(stderr," Problems allocating for material set names\n");
5041 return(Z_ERR);
5046 err = USERD_get_matf_set_info(msids,msname);
5047 if(err == Z_ERR) {
5048 fprintf(stderr,"Error: getting material set info\n");
5050 else {
5051 for(i=0; i<Num_materials_sets; ++i) {
5053 /* Echo some feedback
5054 *-------------------*/
5055 fprintf(stderr," For Material set %d:\n",i+1);
5057 fprintf(stderr," id: %d\n",msids[i]);
5058 fprintf(stderr," name: %s\n",msname[i]);
5060 num_materials[i] = USERD_get_number_of_materials(i);
5061 if(num_materials[i] < 0) {
5062 fprintf(stderr,"Error: getting the number of materials in set %d\n",i);
5063 return (Z_ERR);
5065 else if(num_materials[i] == 0) {
5066 fprintf(stderr," No materials in Materials set %d\n",i);
5067 return (Z_OK);
5069 else {
5070 mids = (int *) calloc(num_materials[i],sizeof(int));
5071 if(mids == (int *)NULL) {
5072 fprintf(stderr," Problems allocating for material ids\n");
5073 return(Z_ERR);
5076 mdesc = (char **) calloc(num_materials[i],sizeof(char *));
5077 if(mdesc == (char **)NULL) {
5078 fprintf(stderr," Problems allocating for material desc\n");
5079 return(Z_ERR);
5081 else {
5082 for(j=0; j<num_materials[i]; ++j) {
5083 mdesc[j] = (char *) calloc(Z_BUFL,sizeof(char));
5084 if(mdesc[j] == (char *)NULL) {
5085 fprintf(stderr," Problems allocating for material desc\n");
5086 return(Z_ERR);
5091 err = USERD_get_matf_var_info(i,mids,mdesc);
5092 if(err == Z_ERR) {
5093 fprintf(stderr,"Error: getting material info\n");
5095 else {
5097 for(j=0; j<num_materials[i]; ++j) {
5098 /* Echo some feedback
5099 *-------------------*/
5100 fprintf(stderr," For Material %d:\n",j+1);
5102 fprintf(stderr," index: %d\n",mids[j]);
5103 fprintf(stderr," description: %s\n",mdesc[j]);
5110 /* Free the allocated memory
5111 *--------------------------*/
5112 for(i=0; i<Num_materials_sets; ++i) {
5113 free(msname[i]);
5115 for(j=0; j<num_materials[i]; ++j) {
5116 free(mdesc[j]);
5119 free(msname);
5120 free(msids);
5121 free(num_materials);
5122 free(mdesc);
5123 free(mids);
5125 return(Z_OK);
5129 /*----------------------
5130 * gold_materials_loader
5131 *----------------------*/
5132 static int
5133 gold_materials_loader(int geom_time_step)
5135 int i, j, k, ms, nn;
5136 int err, err1, err2;
5137 int geom_timeset;
5138 int p, pn;
5139 int et, e1, e2;
5140 int num_dims;
5141 int comp;
5142 int bdim[3];
5143 int ne;
5144 int cell_type;
5145 int bd1,bd2,bd3;
5146 int *ivals;
5147 float *fvals;
5148 int do_num;
5149 int mixed_present;
5150 int matf_size, matfv_size;
5153 fprintf(stderr,"\n-------------- materials_loader --------------\n");
5155 if(Num_time_sets > 0) {
5156 /* Get the timeset used for the geometry
5157 *--------------------------------------*/
5158 geom_timeset = USERD_get_geom_timeset_number();
5160 /* Get the number of time steps for this timeset
5161 *----------------------------------------------*/
5162 Num_time_steps = USERD_get_num_of_time_steps(geom_timeset);
5163 if(Num_time_steps < 1) {
5164 fprintf(stderr," Error: Num time steps returned: %d\n",Num_time_steps);
5165 fprintf(stderr," (Must be >0 to be okay)\n");
5166 return(Z_ERR);
5168 if(geom_time_step > (Num_time_steps - 1)) {
5169 geom_time_step = Num_time_steps - 1;
5172 /* Set the timeset and step - to first step by default, but
5173 * can set it at others using -gts command argument
5174 *---------------------------------------------------------*/
5175 USERD_set_time_set_and_step(geom_timeset,geom_time_step);
5177 fprintf(stderr," Using timeset: %d (step range is %d through %d)\n",
5178 geom_timeset,0,Num_time_steps-1);
5179 fprintf(stderr," Using time step: %d\n",geom_time_step);
5182 for(ms=0; ms<Num_materials_sets; ++ms) {
5183 fprintf(stderr,"\n");
5184 fprintf(stderr," Materials Set %d:\n",ms+1);
5186 for(p=0; p<Num_parts; ++p) {
5187 pn = p+1;
5189 fprintf(stderr,"\n");
5190 fprintf(stderr," Part %d:\n",pn);
5192 /*-----------------------
5193 * For unstructured parts
5194 *-----------------------*/
5195 if(Pbuild[p].type == Z_UNSTRUCTURED) {
5197 e1 = 0;
5198 e2 = Z_MAXTYPE;
5200 else {
5201 for(comp=0; comp<3; ++comp) {
5202 if(Pbuild[p].ne[comp] < 1) {
5203 bdim[comp] = 1;
5205 else {
5206 bdim[comp] = Pbuild[p].ne[comp];
5209 nn = bdim[0] * bdim[1] * bdim[2];
5211 bd1 = bdim[0]-1;
5212 if(bd1 < 1) {
5213 bd1 = 1;
5215 bd2 = bdim[1]-1;
5216 if(bd2 < 1) {
5217 bd2 = 1;
5219 bd3 = bdim[2]-1;
5220 if(bd3 < 1) {
5221 bd3 = 1;
5223 ne = bd1 * bd2 * bd3;
5225 /* Determine cell type
5226 *--------------------*/
5227 num_dims = 3;
5228 for(i=0; i<3; ++i) {
5229 if(bdim[i] == 1) {
5230 --num_dims;
5233 if(num_dims == 3) {
5234 cell_type = Z_HEX08;
5236 else if(num_dims == 2) {
5237 cell_type = Z_QUA04;
5239 else {
5240 cell_type = Z_BAR02;
5243 e1 = cell_type;
5244 e2 = cell_type + 1;
5248 for(et=e1; et<e2; ++et) {
5250 if(Pbuild[p].type == Z_UNSTRUCTURED) {
5251 ne = Pbuild[p].ne[et];
5254 if(ne > 0) {
5256 /* Get the material ids, if any
5257 *-----------------------------*/
5258 err = USERD_size_matf_data(ms,
5261 Z_MAT_INDEX,
5262 &matf_size);
5263 if(err == Z_OK && matf_size > 0) {
5266 /* Go get the material ids
5267 *------------------------*/
5268 ivals = (int *) calloc(matf_size,sizeof(int));
5269 if(ivals == (int *)NULL) {
5270 fprintf(stderr," Problems allocating for material ids\n");
5271 return(Z_ERR);
5273 err = USERD_load_matf_data(ms,
5276 Z_MAT_INDEX,
5277 ivals,
5278 fvals);
5279 if(err == Z_OK) {
5280 if(matf_size < 20) {
5281 fprintf(stderr," Printing all mat ids for %s elements\n",
5282 Elem_info[et].name);
5283 do_num = matf_size;
5285 else {
5286 fprintf(stderr," Printing first 20 mat ids for %s elements\n",
5287 Elem_info[et].name);
5288 do_num = 20;
5291 /* See if any mixed materials
5292 *---------------------------*/
5293 mixed_present = FALSE;
5294 for(k=0; k<matf_size; ++k) {
5295 if(ivals[k] < 0) {
5296 mixed_present = TRUE;
5297 break;
5301 /* Feedback
5302 *---------*/
5303 for(k=0; k<do_num; ++k) {
5304 fprintf(stderr," mat id[%d] = %d\n",k,ivals[k]);
5306 free(ivals);
5308 else {
5309 fprintf(stderr," Trouble getting mat ids for %s elements\n",
5310 Elem_info[et].name);
5311 free(ivals);
5312 return(Z_ERR);
5315 else {
5316 fprintf(stderr," %s elements have no material ids\n",
5317 Elem_info[et].name);
5321 /* Get the mixed material ids, if any
5322 *-----------------------------------*/
5323 if(mixed_present) {
5324 err1 = USERD_size_matf_data(ms,
5327 Z_MIX_INDEX,
5328 &matf_size);
5329 err2 = USERD_size_matf_data(ms,
5332 Z_MIX_VALUE,
5333 &matfv_size);
5335 if(err1 == Z_OK &&
5336 err2 == Z_OK &&
5337 matf_size > 0 &&
5338 matfv_size > 0) {
5340 /* Go get the material ids
5341 *------------------------*/
5342 ivals = (int *) calloc(matf_size,sizeof(int));
5343 if(ivals == (int *)NULL) {
5344 fprintf(stderr," Problems allocating for mixed material ids\n");
5345 return(Z_ERR);
5347 fvals = (float *) calloc(matfv_size,sizeof(float));
5348 if(fvals == (float *)NULL) {
5349 fprintf(stderr," Problems allocating for mixed material values\n");
5350 return(Z_ERR);
5353 err1 = USERD_load_matf_data(ms,
5356 Z_MIX_INDEX,
5357 ivals,
5358 fvals);
5360 err2 = USERD_load_matf_data(ms,
5363 Z_MIX_VALUE,
5364 ivals,
5365 fvals);
5366 if(err1 == Z_OK &&
5367 err2 == Z_OK) {
5368 if(matf_size < 20) {
5369 fprintf(stderr," Printing all mixed mat ids for %s elements\n",
5370 Elem_info[et].name);
5371 do_num = matf_size;
5373 else {
5374 fprintf(stderr," Printing first 20 mixed mat ids for %s elements\n",
5375 Elem_info[et].name);
5376 do_num = 20;
5378 for(k=0; k<do_num; ++k) {
5379 fprintf(stderr," mixed mat id[%d] = %d\n",k,ivals[k]);
5381 free(ivals);
5383 if(matfv_size < 20) {
5384 fprintf(stderr," Printing all mixed mat values for %s elements\n",
5385 Elem_info[et].name);
5386 do_num = matfv_size;
5388 else {
5389 fprintf(stderr," Printing first 20 mixed mat values for %s elements\n",
5390 Elem_info[et].name);
5391 do_num = 20;
5393 for(k=0; k<do_num; ++k) {
5394 fprintf(stderr," mixed mat val[%d] = %f\n",k,fvals[k]);
5396 free(fvals);
5398 else {
5399 fprintf(stderr," Trouble getting mixed mat ids or vals for %s elements\n",
5400 Elem_info[et].name);
5401 free(ivals);
5402 free(fvals);
5403 return(Z_ERR);
5406 else {
5407 fprintf(stderr," Trouble getting mixed mat sizes for %s elements\n",
5408 Elem_info[et].name);
5409 return(Z_ERR);
5412 else {
5413 fprintf(stderr," (%s elements have no mixed material ids)\n",
5414 Elem_info[et].name);
5420 return(Z_OK);
5423 #endif
5426 /*--------------
5427 * entity_querys
5428 *--------------*/
5429 static int
5430 entity_querys(int var_time_step)
5432 int i, j;
5433 int err;
5434 int v, vn;
5435 int var_timeset;
5436 int p, pn;
5437 int et, e1, e2;
5438 int num_comps;
5439 int num_dims;
5440 int nsize;
5441 int comp;
5442 int bdim[3];
5443 int ne;
5444 int cell_type;
5445 char line1[Z_BUFL];
5446 char line2[Z_BUFL];
5447 float qvals[3];
5448 int bd1,bd2,bd3;
5451 fprintf(stderr,"\n-------------- entity_querys ------------\n");
5452 fprintf(stderr," (scalar & vector variables only) \n");
5453 fprintf(stderr,"\n");
5455 #if (defined USERD_API_100)
5457 if(Num_time_steps > 1) {
5458 /* Get the number of time steps for this timeset
5459 *----------------------------------------------*/
5460 if(var_time_step > (Num_time_steps - 1)) {
5461 var_time_step = Num_time_steps - 1;
5464 /* Set the time step - to first step by default, but
5465 * can set it at others using -vts command argument
5466 *---------------------------------------------------------*/
5467 USERD_set_time_step(var_time_step);
5469 fprintf(stderr," Using time step: %d (where range is %d through %d)\n\n",
5470 var_time_step,0,Num_time_steps-1);
5472 #endif
5474 for(v=0; v<Num_vars; ++v) {
5475 vn = v + 1;
5477 /* Scalar or vectors only
5478 *-----------------------*/
5479 if(Varinfo[v].type == Z_SCALAR || Varinfo[v].type == Z_VECTOR) {
5482 if(Varinfo[v].classify == Z_PER_NODE) {
5483 fprintf(stderr," Z_PER_NODE Variable %d:\n",vn);
5485 else {
5486 fprintf(stderr," Z_PER_ELEM Variable %d:\n",vn);
5489 #if (defined GT_USERD_API_100)
5491 if(Num_time_sets > 0) {
5492 /* Get the timeset used for the variable
5493 *---------------------------------------*/
5494 var_timeset = Varinfo[v].timeset;
5496 /* Get the number of time steps for this timeset
5497 *----------------------------------------------*/
5498 Num_time_steps = USERD_get_num_of_time_steps(var_timeset);
5499 if(Num_time_steps < 1) {
5500 fprintf(stderr," Error: Number of time steps returned: %d\n",
5501 Num_time_steps);
5502 fprintf(stderr," (Must be >0 to be okay)\n");
5503 return(Z_ERR);
5505 if(var_time_step > (Num_time_steps - 1)) {
5506 var_time_step = Num_time_steps - 1;
5509 /* Set the timeset and step - to first step by default, but
5510 * can set it at others using -vts command argument
5511 *---------------------------------------------------------*/
5512 USERD_set_time_set_and_step(var_timeset,var_time_step);
5514 fprintf(stderr," Using timeset: %d (step range is %d through %d)\n",
5515 var_timeset,0,Num_time_steps-1);
5516 fprintf(stderr," Using time step: %d\n",var_time_step);
5518 #endif
5521 /* Get the var description line
5522 *-----------------------------*/
5523 #if (defined GT_USERD_API_100)
5524 err = USERD_get_descrip_lines(Z_VARI,vn,FALSE,line1,line2);
5525 if(err == Z_OK) {
5526 fprintf(stderr," Desc line: %s\n",line1);
5528 else {
5529 fprintf(stderr,"Error: getting var description line\n");
5530 return(Z_ERR);
5533 if(Varinfo[v].complex) {
5534 err = USERD_get_descrip_lines(Z_VARI,vn,TRUE,line1,line2);
5535 if(err == Z_OK) {
5536 fprintf(stderr," Desc line (imag): %s\n",line1);
5538 else {
5539 fprintf(stderr,"Error: getting var description line (imag)\n");
5540 return(Z_ERR);
5543 #else
5545 err = USERD_get_description_lines(Z_VARI,vn,line1,line2);
5546 if(err == Z_OK) {
5547 fprintf(stderr," Desc line: %s\n",line1);
5549 else {
5550 fprintf(stderr,"Error: getting var description line\n");
5551 return(Z_ERR);
5554 #endif
5556 /* Get the values by component
5557 *-----------------------------*/
5558 if(Varinfo[v].type == Z_SCALAR) {
5559 num_comps = 1;
5561 else if(Varinfo[v].type == Z_VECTOR) {
5562 num_comps = 3;
5565 /* Per_Node
5566 *---------*/
5567 if(Varinfo[v].classify == Z_PER_NODE) {
5569 for(p=0; p<Num_parts; ++p) {
5570 pn = p + 1;
5572 if(Pbuild[p].type == Z_UNSTRUCTURED) {
5573 nsize = Pbuild[p].nn;
5575 else {
5576 for(comp=0; comp<3; ++comp) {
5577 if(Pbuild[p].ne[comp] < 1) {
5578 bdim[comp] = 1;
5580 else {
5581 bdim[comp] = Pbuild[p].ne[comp];
5584 nsize = bdim[0] * bdim[1] * bdim[2];
5589 if(nsize > 0) {
5591 fprintf(stderr," For part %d, using node %d:\n",pn,nsize);
5593 #if (defined GT_USERD_API_100)
5594 err = USERD_get_var_value_at_specific(vn,
5595 nsize,
5598 var_time_step,
5599 qvals,
5600 FALSE);
5601 #else
5602 err = USERD_get_variable_value_at_specific(vn,
5603 nsize,
5606 var_time_step,
5607 qvals);
5608 #endif
5609 if(err == Z_NOT_IMPLEMENTED) {
5610 fprintf(stderr," Node and element queries not implemented\n");
5611 return(Z_OK);
5613 else if(err == Z_ERR) {
5614 fprintf(stderr," Could not get value\n");
5616 else {
5618 /* For the component, show 1st node, last node, min, max values
5619 *-------------------------------------------------------------*/
5620 if(Varinfo[v].type == Z_SCALAR) {
5621 fprintf(stderr," Scalar value is: %g\n",qvals[0]);
5623 else {
5624 fprintf(stderr," Vector values are: %g %g %g\n",
5625 qvals[0],qvals[1],qvals[2]);
5628 #if (defined GT_USERD_API_100)
5629 if(Varinfo[v].complex) {
5631 err = USERD_get_var_value_at_specific(vn,
5632 nsize,
5635 var_time_step,
5636 qvals,
5637 TRUE);
5639 if(err == Z_ERR) {
5640 fprintf(stderr," Could not get imag value\n");
5642 else {
5644 /* For the component, show 1st node, last node, min, max values
5645 *-------------------------------------------------------------*/
5646 if(Varinfo[v].type == Z_SCALAR) {
5647 fprintf(stderr," Scalar value (imag) is: %g\n",qvals[0]);
5649 else {
5650 fprintf(stderr," Vector values (imag) are: %g %g %g\n",
5651 qvals[0],qvals[1],qvals[2]);
5655 #endif
5662 /* Per_Elem
5663 *---------*/
5664 else {
5665 for(p=0; p<Num_parts; ++p) {
5666 pn = p + 1;
5668 if(Pbuild[p].type != Z_UNSTRUCTURED) {
5670 for(comp=0; comp<3; ++comp) {
5671 if(Pbuild[p].ne[comp] < 1) {
5672 bdim[comp] = 1;
5674 else {
5675 bdim[comp] = Pbuild[p].ne[comp];
5678 bd1 = bdim[0]-1;
5679 if(bd1 < 1) {
5680 bd1 = 1;
5682 bd2 = bdim[1]-1;
5683 if(bd2 < 1) {
5684 bd2 = 1;
5686 bd3 = bdim[2]-1;
5687 if(bd3 < 1) {
5688 bd3 = 1;
5690 nsize = bd1 * bd2 * bd3;
5693 /* Determine cell type
5694 *--------------------*/
5695 num_dims = 3;
5696 for(i=0; i<3; ++i) {
5697 if(bdim[i] == 1) {
5698 --num_dims;
5701 if(num_dims == 3) {
5702 cell_type = Z_HEX08;
5704 else if(num_dims == 2) {
5705 cell_type = Z_QUA04;
5707 else {
5708 cell_type = Z_BAR02;
5712 if(Pbuild[p].type == Z_UNSTRUCTURED) {
5713 e1 = 0;
5714 e2 = Z_MAXTYPE-1;
5716 else {
5717 e1 = e2 = cell_type;
5720 for(et=e1; et<=e2; ++et) {
5722 if(Pbuild[p].type == Z_UNSTRUCTURED) {
5723 nsize = Pbuild[p].ne[et];
5726 if(nsize > 0) {
5729 fprintf(stderr," For part %d, using elem %d of type %s:\n",
5730 pn,nsize,Elem_info[et].name);
5733 #if (defined GT_USERD_API_100)
5734 err = USERD_get_var_value_at_specific(vn,
5735 nsize,
5738 var_time_step,
5739 qvals,
5740 FALSE);
5741 #else
5742 err = USERD_get_variable_value_at_specific(vn,
5743 nsize,
5746 var_time_step,
5747 qvals);
5748 #endif
5750 if(err == Z_NOT_IMPLEMENTED) {
5751 fprintf(stderr," Node and element queries not implemented\n");
5752 return(Z_OK);
5754 else if(err == Z_ERR) {
5755 fprintf(stderr," Could not get value\n");
5757 else {
5758 if(Varinfo[v].type == Z_SCALAR) {
5759 fprintf(stderr," Scalar value is: %g\n",qvals[0]);
5761 else {
5762 fprintf(stderr," Vector values are: %g %g %g\n",
5763 qvals[0],qvals[1],qvals[2]);
5766 #if (defined GT_USERD_API_100)
5767 if(Varinfo[v].complex) {
5769 err = USERD_get_var_value_at_specific(vn,
5770 nsize,
5773 var_time_step,
5774 qvals,
5775 TRUE);
5776 if(err == Z_ERR) {
5777 fprintf(stderr," Could not get imag value\n");
5779 else {
5780 if(Varinfo[v].type == Z_SCALAR) {
5781 fprintf(stderr," Scalar value (imag) is: %g\n",qvals[0]);
5783 else {
5784 fprintf(stderr," Vector values (imag) are: %g %g %g\n",
5785 qvals[0],qvals[1],qvals[2]);
5789 #endif
5798 return(Z_OK);
5802 /*--------------
5803 * exercise_bkup
5804 *--------------*/
5805 static int
5806 exercise_bkup( void )
5808 int err;
5809 FILE *arcfile;
5811 fprintf(stderr,"\n------------ exercise_archive -----------\n");
5813 arcfile = fopen("test.arc","wb");
5814 if(arcfile == (FILE *)NULL) {
5815 fprintf(stderr,"Error: opening test archive file\n");
5816 return(Z_ERR);
5818 err = USERD_bkup(arcfile,Z_SAVE_ARCHIVE);
5819 if(err == Z_ERR) {
5820 fprintf(stderr,"Error: saving to test archive file\n");
5821 return(Z_ERR);
5823 fclose(arcfile);
5825 arcfile = fopen("test.arc","rb");
5826 err = USERD_bkup(arcfile,Z_REST_ARCHIVE);
5827 if(err == Z_ERR) {
5828 fprintf(stderr,"Error: restoring from test archive file\n");
5829 return(Z_ERR);
5832 fprintf(stderr," Archive test completed\n");
5834 fclose(arcfile);
5836 return(Z_OK);
5839 /* -------------------------------------------------------
5840 * threshold_operator1 & 2 can be one of the following
5841 * Z_ELE_FAILED_NONE, - disables checking
5842 * Z_ELE_FAILED_GREATER, - greater than
5843 * Z_ELE_FAILED_LESS, - less than
5844 * Z_ELE_FAILED_EQUAL, - equal
5845 * Z_ELE_FAILED_NOT_EQUAL, - not equal
5846 * Z_ELE_FAILED_MANY - not used
5848 * logic_criteria2
5849 * Z_ELE_FAILED_LOGIC_NONE,
5850 * Z_ELE_FAILED_LOGIC_AND,
5851 * Z_ELE_FAILED_LOGIC_OR,
5852 * Z_ELE_FAILED_LOGIC_MANY
5854 * ------------------------------------------------------ */
5855 int load_fail_defaults(void)
5857 int check_for_failed = FALSE;
5858 int cri1 = 0; /* Criteria1 ELE_FAILED_GREATER, etc */
5859 int cri2 = 0;
5860 int logic_cri2 = 0; /* Logic for criteria 2 ELE_FAILED_LOGIC_NONE, AND, etc */
5861 float val1 = 0.0; /* failure threshold 1 */
5862 float val2= 0.0; /* failure threshold 2 */
5863 char failed_var_name[Z_MXVARIABLEDESC]={EOS};
5865 check_for_failed = USERD_get_uns_failed_params( failed_var_name,
5866 &val1, &val2, &cri1, &cri2,
5867 &logic_cri2 );
5868 fprintf(stderr,"\n------------- failed element info -------------\n");
5869 if (check_for_failed == TRUE) {
5870 fprintf(stderr," Failed element criteria info \n");
5871 fprintf(stderr," Variable name = %s\n",failed_var_name);
5872 fprintf(stderr," Criteria 1 = %d\n",cri1);
5873 fprintf(stderr," Criteria 2 = %d\n",cri1);
5874 fprintf(stderr," Logic criteria = %d\n",logic_cri2);
5875 fprintf(stderr," Value 1 = %f\n",val1);
5876 fprintf(stderr," Value 2 = %f\n",val2);
5877 } else {
5878 fprintf(stderr," No Failed elements\n");
5880 return(Z_OK);
5884 /* End of File */