ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / applications / test / ensightFoamReader / udr_checker-80.c
blob22fb6feb5386cd86ae8c9d77f5320d55e1a2e159
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 #define _EGS)
200 * USERD_get_extra_gui_defaults (optional #define _EGS)
202 * Set the filenames
203 * =================
204 * USERD_set_extra_gui_data (optional #define _EGS)
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 the Extra GUI stuff
317 * you need to uncomment this section
319 * #define _EGS
321 * ----------------------------------------------- */
323 #if (!defined USERD_API_100)
324 #define GT_USERD_API_100
325 #endif
327 #if (!defined USERD_API_100 && !defined USERD_API_200)
328 #define GT_USERD_API_200
329 #endif
331 #if (!defined USERD_API_100 && !defined USERD_API_200 && !defined USERD_API_201 && !defined USERD_API_202)
332 #define GT_USERD_API_202
333 #endif
335 #if (!defined USERD_API_100 && !defined USERD_API_200 && !defined USERD_API_201 && !defined USERD_API_202 && !defined USERD_API_203)
336 #define GT_USERD_API_203
337 #endif
340 #define EOS '\0'
342 typedef struct {
343 int id; /* part_id */
344 char desc[Z_BUFL]; /* description given in the file */
345 int type; /* Z_UNSTRUCTURED, Z_STRUCTURED, Z_IBLANKED */
346 int ne[Z_MAXTYPE]; /* Number of elements per type (Z_UNSTRUCTURED) */
347 /* or ne[0] = I dimension (Z_STRUCTURED) */
348 /* ne[1] = J dimension */
349 /* ne[2] = K dimension */
350 int nn; /* Num of unstructured nodes (All_Local only) */
351 int ghosts; /* TRUE if ghost cells, FALSE otherwise */
352 }BUILDINFO;
354 typedef struct {
355 char description[Z_BUFL]; /* description */
356 char filename[Z_BUFL]; /* real filename */
357 char ifilename[Z_BUFL]; /* imaginary filename */
358 int type;
359 int classify;
360 int complex;
361 float freq;
362 int contran;
363 int timeset;
364 }VARINFO;
367 typedef struct {
368 char name[12]; /* Z_POINT, Z_G_POINT, Z_BAR02, ... */
369 int con_len; /* Number of nodes per element */
370 }EINFO;
373 /* Global variables
374 *-----------------*/
375 int Geom_status;
376 int Node_labels;
377 int Element_labels;
378 int Ghosts_in_model;
379 int Num_parts;
380 int Num_vars;
381 int Num_materials_sets;
382 BUILDINFO *Pbuild;
383 VARINFO *Varinfo;
384 char Version_number[Z_MAX_USERD_NAME];
385 int Num_time_sets;
386 int Num_time_steps;
388 /* ------------------
389 * Extra GUI stuff
390 * ------------------ */
391 int Num_toggles = 0;
392 int Num_pulldowns = 0;
393 int Num_fields = 0;
394 char **Toggle_title;
395 int *Toggle_default_status;
396 char **Pulldown_title;
397 int *Pulldown_number_in_list;
398 int *Pulldown_default_selection;
399 char ***Pulldown_item_strings;
400 char **Field_title;
401 char **Field_user_string;
402 int *Toggle_choice; /* user choice */
403 int *Pulldown_choice; /* user choice */
405 /* ---------------------------
406 * Failed elements (API 2.04)
407 * --------------------------- */
408 int Any_uns_failed_model_elems = FALSE;
411 #if (defined USERD_API_100 || defined USERD_API_200)
412 EINFO Elem_info[Z_MAXTYPE] = {"Z_POINT",1,
413 "Z_BAR02",2,
414 "Z_BAR03",3,
415 "Z_TRI03",3,
416 "Z_TRI06",6,
417 "Z_QUA04",4,
418 "Z_QUA08",8,
419 "Z_TET04",4,
420 "Z_TET10",10,
421 "Z_PYR05",5,
422 "Z_PYR13",13,
423 "Z_PEN06",6,
424 "Z_PEN15",15,
425 "Z_HEX08",8,
426 "Z_HEX20",20};
427 #elif defined USERD_API_201
428 EINFO Elem_info[Z_MAXTYPE] = {"Z_POINT", 1,
429 "Z_G_POINT",1,
430 "Z_BAR02", 2,
431 "Z_G_BAR02",2,
432 "Z_BAR03", 3,
433 "Z_G_BAR03",3,
434 "Z_TRI03", 3,
435 "Z_G_TRI03",3,
436 "Z_TRI06", 6,
437 "Z_G_TRI06",6,
438 "Z_QUA04", 4,
439 "Z_G_QUA04",4,
440 "Z_QUA08", 8,
441 "Z_G_QUA08",8,
442 "Z_TET04", 4,
443 "Z_G_TET04",4,
444 "Z_TET10", 10,
445 "Z_G_TET10",10,
446 "Z_PYR05", 5,
447 "Z_G_PYR05",5,
448 "Z_PYR13", 13,
449 "Z_G_PYR13",13,
450 "Z_PEN06", 6,
451 "Z_G_PEN06",6,
452 "Z_PEN15", 15,
453 "Z_G_PEN15",15,
454 "Z_HEX08", 8,
455 "Z_G_HEX08",8,
456 "Z_HEX20", 20,
457 "Z_G_HEX20",20};
458 #else
459 EINFO Elem_info[Z_MAXTYPE] = {"Z_POINT", 1,
460 "Z_G_POINT",1,
461 "Z_BAR02", 2,
462 "Z_G_BAR02",2,
463 "Z_BAR03", 3,
464 "Z_G_BAR03",3,
465 "Z_TRI03", 3,
466 "Z_G_TRI03",3,
467 "Z_TRI06", 6,
468 "Z_G_TRI06",6,
469 "Z_QUA04", 4,
470 "Z_G_QUA04",4,
471 "Z_QUA08", 8,
472 "Z_G_QUA08",8,
473 "Z_TET04", 4,
474 "Z_G_TET04",4,
475 "Z_TET10", 10,
476 "Z_G_TET10",10,
477 "Z_PYR05", 5,
478 "Z_G_PYR05",5,
479 "Z_PYR13", 13,
480 "Z_G_PYR13",13,
481 "Z_PEN06", 6,
482 "Z_G_PEN06",6,
483 "Z_PEN15", 15,
484 "Z_G_PEN15",15,
485 "Z_HEX08", 8,
486 "Z_G_HEX08",8,
487 "Z_HEX20", 20,
488 "Z_G_HEX20",20,
489 "Z_NSIDED", 1, /* Not yet implemented */
490 "Z_G_NSIDED",1, /* Not yet implemented */
491 "Z_NFACED", 1, /* Not yet implemented */
492 "Z_G_NFACED",1}; /* Not yet implemented */
493 #endif
496 /* Prototypes
497 *-----------*/
498 static int load_fail_defaults(void);
499 static int prelim_info(int *two_fields, int *any_extra_gui);
500 static int get_input(int set_server_number,
501 int use_playfile,
502 char playfile[Z_MAXFILENP],
503 int two_fields,
504 int any_extra_gui,
505 int *swapbytes);
506 static int time_info( void );
507 static int part_build_info(int geom_time_step);
508 static int variable_info( void );
510 #if (defined GT_USERD_API_100)
511 static int gold_part_builder(int geom_time_step);
512 static int gold_var_loader(int var_time_step);
513 #else
514 static int part_builder(int geom_time_step);
515 static int var_loader(int var_time_step);
516 #endif
518 #if (defined GT_USERD_API_100)
519 static int materials_info( void );
520 static int gold_materials_loader(int geom_time_step);
521 #endif
523 static int entity_querys(int var_time_step);
524 static int exercise_bkup( void );
525 static void usage( void );
528 /*=============
529 * Main Routine
530 *=============*/
531 #ifdef WIN32
532 int main(int argc, char *argv[])
533 #else
534 int main(int argc, char *argv[])
535 #endif
537 /* Command line option variables
538 *------------------------------*/
539 int set_server_number = FALSE;
540 int use_playfile = FALSE;
541 char playfile[Z_MAXFILENP];
542 FILE *fplay;
543 int geom_time_step = 0;
544 int var_time_step = 0;
546 /* Other local variables
547 *----------------------*/
548 int i, j;
549 int err;
550 int two_fields;
551 int any_extra_gui = FALSE;
552 int swapbytes;
553 int indx;
555 /*----------------------------
556 * Command argument processing
557 *----------------------------*/
558 fprintf(stderr,"\n");
559 fprintf(stderr,"\n");
560 fprintf(stderr,"********************************************\n");
561 fprintf(stderr,"* EnSight User Defined Reader Debug Tool *\n");
562 fprintf(stderr,"********************************************\n");
563 fprintf(stderr,"\n");
565 indx = 1;
566 while(indx < argc) {
568 if(!strcmp("-h",argv[indx])) {
569 usage();
571 else if(!strcmp("-help",argv[indx])) {
572 usage();
575 /* if you want to test the server number routines
577 * Use:
578 * > checker -server_number
580 * You will then be prompted for the current and total
581 * number of servers
582 *-----------------------------------------------*/
583 else if(!strcmp("-server_number",argv[indx])) {
584 set_server_number = TRUE;
588 /* if you want to use a "playfile" instead of being prompted
589 * for the data loader information
591 * Use:
592 * > checker -p <playfile>
594 * This playfile should have 3 [or 4] lines:
595 * line 1: the path
596 * line 2: filename_1
597 * line 3: [filename_2] (if two_fields is TRUE)
598 * line 4: 0 or 1, for swapytes (0 is FALSE, 1 is TRUE)
600 * example (two_fields is FALSE, so only 3 lines):
602 * /usr/scratch/stealth/bjn/dat/sp_gold/binary
603 * simple.case
606 *------------------------------------------------------*/
607 else if(!strcmp("-p",argv[indx])) {
608 indx++;
609 if((indx < argc) && (argv[indx][0] != '-')) {
610 use_playfile = TRUE;
611 memset(playfile,EOS,Z_MAXFILENP);
612 strcpy(playfile,argv[indx]);
614 else {
615 usage();
619 /* if you want to specify the geometry timestep to test (default is step 0)
621 * Use:
622 * > checker -gts #
624 * Where # is the step number (zero based)
625 *-------------------------------------------------------------------------*/
626 else if(!strcmp("-gts",argv[indx])) {
627 indx++;
628 if((indx < argc) && (argv[indx][0] != '-')) {
629 geom_time_step = atoi(argv[indx]);
631 else {
632 usage();
636 /* if you want to specify the variable timestep to test (default is step 0)
637 * (will use this step for the appropriate timeset of each variable)
639 * Use:
640 * > checker -vts #
642 * Where # is the step number (zero based)
643 *-------------------------------------------------------------------------*/
644 else if(!strcmp("-vts",argv[indx])) {
645 indx++;
646 if((indx < argc) && (argv[indx][0] != '-')) {
647 var_time_step = atoi(argv[indx]);
649 else {
650 usage();
653 else {
654 usage();
657 indx++;
661 /*-------------------------------------------------------------
663 * Now start exercising EnSight
665 *--------------------------------------------------------------*/
667 /*-----------------
668 * Preliminary info
669 *-----------------*/
670 err = prelim_info(&two_fields,&any_extra_gui);
671 if(err == Z_ERR) {
672 fprintf(stderr,"Stopping because of error in prelim_info\n");
673 exit(1);
677 /*------------------
678 * User input needed
679 *------------------*/
680 err = get_input(set_server_number,
681 use_playfile,
682 playfile,
683 two_fields,
684 any_extra_gui,
685 &swapbytes);
686 if(err == Z_ERR) {
687 fprintf(stderr,"Stopping because of error in get_input\n");
688 exit(1);
692 /*----------
693 * Time info
694 *----------*/
695 err = time_info();
696 if(err == Z_ERR) {
697 fprintf(stderr,"Stopping because of error in time_info\n");
698 exit(1);
702 /*----------------
703 * Part build info
704 *----------------*/
705 err = part_build_info(geom_time_step);
706 if(err == Z_ERR) {
707 fprintf(stderr,"Stopping because of error in part_build_info\n");
708 exit(1);
712 /*------------------
713 * Get Variable Info
714 *------------------*/
715 err = variable_info();
716 if(err == Z_ERR) {
717 fprintf(stderr,"Stopping because of error in variable_info\n");
718 exit(1);
722 #if (defined GT_USERD_API_202)
723 /*-------------------
724 * Get Materials Info
725 *-------------------*/
726 err = materials_info();
727 if(err == Z_ERR) {
728 fprintf(stderr,"Stopping because of error in materials_info\n");
729 exit(1);
731 #endif
733 #if (defined GT_USERD_API_203)
734 if (Z_ERR == load_fail_defaults()) {
735 fprintf(stderr,"Stopping due to error in failed element flag routine\n");
736 exit(1);
738 #endif
740 /*------------------------
741 * Act like building parts
742 *------------------------*/
743 if(Num_parts > 0) {
745 #if (defined GT_USERD_API_100)
746 err = gold_part_builder(geom_time_step);
747 #else
748 err = part_builder(geom_time_step);
749 #endif
750 if(err == Z_ERR) {
751 fprintf(stderr,"Stopping because of error in part_builder\n");
752 exit(1);
754 else {
755 USERD_stop_part_building();
760 /*---------------------------
761 * Act like loading variables
762 *---------------------------*/
763 if(Num_vars > 0) {
765 #if (defined GT_USERD_API_100)
766 err = gold_var_loader(var_time_step);
767 #else
768 err = var_loader(var_time_step);
769 #endif
770 if(err == Z_ERR) {
771 fprintf(stderr,"Stopping because of error in var_loader\n");
772 exit(1);
776 #if (defined GT_USERD_API_202)
777 /*---------------------------
778 * Act like loading materials
779 *---------------------------*/
780 if(Num_materials_sets > 0) {
781 err = gold_materials_loader(geom_time_step);
782 if(err == Z_ERR) {
783 fprintf(stderr,"Stopping because of error in materials_loader\n");
784 exit(1);
787 #endif
791 /*----------------------------------------------------
792 * See if can do node and/or element queries over time
793 *----------------------------------------------------*/
794 if(Num_parts > 0 &&
795 Num_vars > 0) {
796 err = entity_querys(var_time_step);
797 if(err == Z_ERR) {
798 fprintf(stderr,"Stopping because of error in entity_querys\n");
799 exit(1);
803 /*----------------------------------------
804 * Call the bkup file once in save mode,
805 * then again in restore mode - so someone
806 * could debug if desired
807 *----------------------------------------*/
808 err = exercise_bkup();
809 if(err == Z_ERR) {
810 fprintf(stderr,"Stopping due to error in saving and/or restoring archive\n");
811 exit(1);
814 /*-------------
815 * Exit Routine
816 *-------------*/
817 fprintf(stderr,"\n----------------- exiting ---------------\n");
819 #if (defined GT_USERD_API_100)
820 USERD_exit_routine();
821 #endif
823 fprintf(stderr,"\n\n");
826 /*--------------
827 * Usage routine
828 *--------------*/
829 static void
830 usage( void )
832 fprintf(stderr,"------------------------------------------------------------\n");
833 fprintf(stderr,"USAGE: checker [-p pfile] [-server_number] [-gts #] [-vts #]\n");
834 fprintf(stderr,"------------------------------------------------------------\n");
835 fprintf(stderr," -h, -help Prints out this USAGE text.\n");
836 fprintf(stderr," -gts # Specify the geometry times step to use.)\n");
837 fprintf(stderr," -p pfile Plays the checker playfile (pfile).\n");
838 fprintf(stderr," -server_number Cause servers numbers to be prompted for.\n");
839 fprintf(stderr," -vts # Specify the variable times step to use.)\n");
840 fprintf(stderr,"\n");
841 exit(1);
847 /*------------
848 * prelim_info
849 *------------*/
850 static int
851 prelim_info(int *two_fields, int *any_extra_gui)
853 int err;
854 char reader_name[Z_MAX_USERD_NAME];
855 char release_number[Z_MAX_USERD_NAME];
856 char description[Z_MAXFILENP];
857 int i,j;
859 *any_extra_gui = FALSE;
861 /* Get the reader name
862 *--------------------*/
863 err = USERD_get_name_of_reader(reader_name,two_fields);
864 if(err == Z_OK) {
865 fprintf(stderr," Name of reader: %s\n",reader_name);
866 if(*two_fields==1) {
867 fprintf(stderr," two_fields: TRUE\n");
869 else if(*two_fields==0){
870 fprintf(stderr," two_fields: FALSE\n");
872 else if(*two_fields < 0) {
873 fprintf(stderr," two_fields: -1 (optional string) \n");
876 else {
877 fprintf(stderr,"Error: Could not get name of reader\n");
878 return(Z_ERR);
881 /* Get the Extra GUI stuff (optional)
882 * ---------------------------------------------------------- */
883 #ifdef _EGS
885 /* Get the Extra GUI numbers of toggles, pulldowns, & fields
886 * ---------------------------------------------------------- */
888 USERD_get_extra_gui_numbers( &Num_toggles,
889 &Num_pulldowns,
890 &Num_fields );
892 if ( Num_toggles > 0 || Num_pulldowns > 0 || Num_fields > 0 ) {
895 *any_extra_gui = TRUE;
897 if (Num_toggles>0) {
898 Toggle_title = (char **) calloc(Num_toggles,sizeof(char*));
899 if (Toggle_title == (char **)NULL) return(Z_ERR);
900 for (i=0; i<Num_toggles; i++) {
901 Toggle_title[i] = (char *) calloc(Z_LEN_GUI_TITLE_STR,sizeof(char));
902 if ( Toggle_title[i] == (char *)NULL ) return(Z_ERR);
904 Toggle_default_status = (int *) calloc(Num_toggles,sizeof(int));
905 Toggle_choice = (int *) calloc(Num_toggles,sizeof(int));
908 if (Num_pulldowns > 0) {
909 Pulldown_title = (char **) calloc( Num_pulldowns , sizeof(char*) );
910 if (Pulldown_title == (char **)NULL) return(Z_ERR);
912 Pulldown_item_strings = (char ***) calloc( Num_pulldowns , sizeof(char**) );
913 if (Pulldown_item_strings == (char ***)NULL) return(Z_ERR);
915 for (i=0; i<Num_pulldowns; i++) {
916 Pulldown_title[i] = (char *) calloc( Z_LEN_GUI_TITLE_STR , sizeof(char) );
917 if ( Pulldown_title[i] == (char *)NULL ) return(Z_ERR);
919 Pulldown_item_strings[i] = (char **) calloc( Z_MAX_NUM_GUI_PULL_ITEMS , sizeof(char *) );
920 if (Pulldown_item_strings[i] == (char **)NULL) return(Z_ERR);
922 for(j = 0; j < Z_MAX_NUM_GUI_PULL_ITEMS; j++) {
923 Pulldown_item_strings[i][j] = (char *) calloc( Z_LEN_GUI_PULL_STR , sizeof(char) );
924 if ( Pulldown_item_strings[i][j] == (char *)NULL ) return(Z_ERR);
927 Pulldown_number_in_list = (int *) calloc(Num_pulldowns,sizeof(int));
928 Pulldown_default_selection = (int *) calloc(Num_pulldowns,sizeof(int));
929 Pulldown_choice = (int *) calloc(Num_pulldowns,sizeof(int));
932 if (Num_fields > 0) {
933 Field_title = (char **) calloc(Num_fields,sizeof(char*));
934 Field_user_string = (char **) calloc(Num_fields,sizeof(char*));
935 if (Field_title == (char **) NULL) return(Z_ERR);
936 for (i=0; i<Num_fields; i++) {
937 Field_title[i] = (char *) calloc(Z_LEN_GUI_TITLE_STR,sizeof(char));
938 if ( Field_title[i] == (char *)NULL) return(Z_ERR);
939 Field_user_string[i] = (char *) calloc(Z_LEN_GUI_FIELD_STR,sizeof(char));
940 if ( Field_user_string[i] == (char *)NULL) return(Z_ERR);
945 err = USERD_get_extra_gui_defaults(
946 Toggle_title, /* [num_toggles][Z_LEN_GUI_TITLE_STR] */
947 Toggle_default_status, /* [num_toggles] */
948 Pulldown_title, /* [num_pulldowns][Z_LEN_GUI_TITLE_STR] */
949 Pulldown_number_in_list, /* [num_pulldowns] */
950 Pulldown_default_selection, /* [num_pulldowns] */
951 Pulldown_item_strings, /* [num_pulldowns][Z_MAX_NUM_GUI_PULL_ITEMS][Z_LEN_GUI_PULL_STR] */
952 Field_title, /* [num_fields][Z_LEN_GUI_TITLE_STR] */
953 Field_user_string /* [num_fields][Z_LEN_GUI_FIELD_STR] */
955 if (Z_ERR == err) return(Z_ERR);
957 fprintf(stderr,"\n**********************************************\n");
958 fprintf(stderr,"**** Extra GUI Information ***\n");
959 fprintf(stderr,"**********************************************\n\n");
961 fprintf(stderr,"\nTOGGLE INFO: %d active toggles\n",Num_toggles);
962 for (i=0; i<Num_toggles; i++) {
963 fprintf(stderr,"Toggle Title %d : %s\n",i,Toggle_title[i]);
964 fprintf(stderr,"Default status = %d \n",Toggle_default_status[i]);
967 fprintf(stderr,"\nPULLDOWN INFO: %d active pulldowns\n",Num_pulldowns);
968 for (i=0; i<Num_pulldowns; i++) {
969 fprintf(stderr,"Pulldown Title %d : %s\n", i , Pulldown_title[i] );
970 for (j=0; j<Z_MAX_NUM_GUI_PULL_ITEMS; j++) {
971 fprintf(stderr,"Pulldown_item %d : %s\n",j,Pulldown_item_strings[i][j]);
972 if (strlen(Pulldown_item_strings[i][j]) == 0) {
973 Pulldown_number_in_list[i] = j;
974 break;
977 fprintf(stderr,"Number of items in list: %d\n",Pulldown_number_in_list[i]);
978 fprintf(stderr,"Default selection: %d\n\n",Pulldown_default_selection[i]);
980 fprintf(stderr,"\n");
982 fprintf(stderr,"\nFIELDINFO: %d active fields\n",Num_fields);
983 for (i=0; i<Num_fields; i++) {
984 fprintf(stderr,"Field Title %d : %s\n",i,Field_title[i]);
985 fprintf(stderr,"Field string %d: %s\n",i,Field_user_string[i]);
987 fprintf(stderr,"\n\n\n");
990 #endif
993 #if (defined GT_USERD_API_100)
995 /* Get the reader api used
996 *------------------------*/
997 err = USERD_get_reader_version(Version_number);
998 if(err == Z_OK) {
999 fprintf(stderr," API version: %s\n",Version_number);
1001 else {
1002 fprintf(stderr,"Error: Could not get reader api version\n");
1003 return(Z_ERR);
1006 /* Get the reader release
1007 *-----------------------*/
1008 err = USERD_get_reader_release(release_number);
1009 if(err == Z_OK) {
1010 fprintf(stderr," Release: %s\n",release_number);
1012 else {
1013 fprintf(stderr,"Error: Could not get reader release\n");
1014 return(Z_ERR);
1016 #else
1017 fprintf(stderr," API version: 1.00\n");
1018 #endif
1021 #if 0
1022 /* Get the reader description
1023 *---------------------------*/
1024 err = USERD_get_reader_descrip(description);
1025 if(err == Z_OK) {
1026 fprintf(stderr," Description:\n\n");
1027 fprintf(stderr,"%s\n\n",description);
1029 else {
1030 fprintf(stderr,"Error: Could not get reader description\n");
1031 return(Z_ERR);
1033 #else
1034 fprintf(stderr," Note: Not currently calling USERD_get_reader_descrip\n");
1035 fprintf(stderr," because it is optional.\n");
1036 #endif
1038 return(Z_OK);
1042 /*----------
1043 * get_input
1044 *----------*/
1045 static int
1046 get_input(int set_server_number,
1047 int use_playfile,
1048 char playfile[Z_MAXFILENP],
1049 int two_fields,
1050 int any_extra_gui,
1051 int *swapbytes)
1053 FILE *fplay;
1055 int i, j;
1056 int err;
1057 int tot_servers;
1058 int cur_server;
1059 char the_path[Z_MAXFILENP];
1060 char file1[Z_MAXFILENP];
1061 char file2[Z_MAXFILENP];
1062 char filename_1[Z_MAXFILENP];
1063 char filename_2[Z_MAXFILENP];
1066 fprintf(stderr,"\n-------------- get_input ----------------\n");
1068 /*-----------------------------------------------------
1069 * Prompt for the two input values, as the client would
1070 * And set this info for the reader
1071 *-----------------------------------------------------*/
1073 #if (defined GT_USERD_API_100)
1075 /* Set the server number - if command line option to do so
1076 *--------------------------------------------------------*/
1077 if(set_server_number) {
1078 fprintf(stderr," Enter total number of servers: ");
1079 scanf("%d",&tot_servers);
1081 fprintf(stderr," Enter current server number: ");
1082 scanf("%d",&cur_server);
1084 fprintf(stderr," Setting %d of %d for server number\n",cur_server,tot_servers);
1085 USERD_set_server_number(cur_server,tot_servers);
1087 #endif
1089 /* Set the filenames
1090 *------------------*/
1091 memset(the_path,EOS,Z_MAXFILENP);
1092 memset(file1,EOS,Z_MAXFILENP);
1093 memset(file2,EOS,Z_MAXFILENP);
1094 memset(filename_1,EOS,Z_MAXFILENP);
1095 memset(filename_2,EOS,Z_MAXFILENP);
1098 if(!use_playfile) {
1099 fprintf(stderr," Enter the path: ");
1100 scanf("%s",the_path);
1103 fprintf(stderr," Enter filename_1: ");
1104 scanf("%s",file1);
1106 if(two_fields == TRUE) {
1107 fprintf(stderr," Enter filename_2: ");
1108 scanf("%s",file2);
1111 fprintf(stderr," Enter Swapbytes (0 if FALSE, 1 if TRUE): ");
1112 scanf("%d",swapbytes);
1114 if (TRUE == any_extra_gui ) {
1115 fprintf(stderr,"\n**********************************************\n");
1116 fprintf(stderr,"**** Extra GUI INPUT ***\n");
1117 fprintf(stderr,"**********************************************\n\n");
1119 fprintf(stderr, "\n TOGGLE INPUT \n");
1120 for (i=0; i<Num_toggles; i++) {
1121 fprintf(stderr, " Enter Toggle Value for '%s' (1=toggle on, 0=toggle off)\n",Toggle_title[i]);
1122 scanf("%d",&Toggle_choice[i]);
1124 fprintf(stderr, "\n PULLDOWN INPUT \n");
1125 for (i=0; i<Num_pulldowns; i++) {
1126 fprintf(stderr, "\n PULLDOWN # %d \n",i);
1127 for (j = 0; j<Pulldown_number_in_list[i]; j++) {
1128 fprintf(stderr, " %d %s\n",j,Pulldown_item_strings[i][j]);
1130 fprintf(stderr, " Enter Pulldown Value for '%s' (0 to %d)\n",Pulldown_title[i],Pulldown_number_in_list[i]-1);
1131 scanf("%d",&Pulldown_choice[i]);
1133 fprintf(stderr, "\n FIELD INPUT \n");
1134 for (i=0; i<Num_fields; i++) {
1135 fprintf(stderr, "Enter string for field %d '%s'\n",i,Field_title[i]);
1136 scanf("%s",Field_user_string[i]);
1139 } /* end if there is any extra gui stuff */
1140 } /* end if not using playfile */
1141 else {
1142 fplay = fopen(playfile,"rb");
1143 if(fplay == (FILE *)NULL) {
1144 fprintf(stderr,"Error: Opening the playfile %s\n",playfile);
1145 return(Z_ERR);
1147 else {
1148 fscanf(fplay,"%s",the_path);
1149 fscanf(fplay,"%s",file1);
1150 if(two_fields == TRUE) {
1151 fscanf(fplay,"%s",file2);
1153 fscanf(fplay,"%d",swapbytes);
1155 /* ---------------------
1156 * Extra GUI stuff
1157 * --------------------- */
1158 if (TRUE == any_extra_gui) {
1160 for (i=0; i<Num_toggles; i++) {
1161 fscanf(fplay,"%d",&Toggle_choice[i]);
1164 for (i=0; i<Num_pulldowns; i++) {
1165 fscanf(fplay,"%d",&Pulldown_choice[i]);
1168 for (i=0; i<Num_fields; i++) {
1169 fscanf(fplay,"%s",Field_user_string[i]);
1172 fclose(fplay);
1176 #ifdef _EGS
1177 /* -------------------------------------------
1178 * set the user choices here and run the code
1179 * ------------------------------------------- */
1181 /* set your choices here
1182 Toggle_choice[0..Num_toggles]
1183 Pulldown_choice[0..Num_pulldowns]
1184 Field_user_string[Num_fields][0..Numfields]
1185 amd then send your choices into this routine */
1187 USERD_set_extra_gui_data(
1188 Toggle_choice, /* [num_toggle] */
1189 Pulldown_choice, /* [num_pulldown] */
1190 Field_user_string ); /* [num_fields][Z_LEN_GUI_FIELD_STR] */
1192 for (i=0; i<Num_toggles; i++) {
1193 fprintf(stderr,"Toggle Title %d : %s\n",i,Toggle_title[i]);
1194 fprintf(stderr,"User selection = %d \n",Toggle_choice[i]);
1196 fprintf(stderr,"\n\n");
1198 for (i=0; i<Num_pulldowns; i++) {
1199 fprintf(stderr,"Pulldown Title %d : %s\n", i , Pulldown_title[i] );
1200 fprintf(stderr,"Pulldown selection is # %d : %s\n",Pulldown_choice[i],Pulldown_item_strings[i][Pulldown_choice[i]]);
1203 for (i=0; i<Num_fields; i++) {
1204 fprintf(stderr,"Field Title %d : %s\n",i,Field_title[i]);
1205 fprintf(stderr,"Field string %d: %s\n",i,Field_user_string[i]);
1210 #endif
1212 if(strncmp(file1,"/",1)) {
1213 strcpy(filename_1,the_path);
1214 strcat(filename_1,"/");
1215 strcat(filename_1,file1);
1217 if(two_fields == TRUE) {
1218 if(strncmp(file2,"/",1)) {
1219 strcpy(filename_2,the_path);
1220 strcat(filename_2,"/");
1221 strcat(filename_2,file2);
1224 if(*swapbytes == 0) {
1225 *swapbytes = FALSE;
1227 else {
1228 *swapbytes = TRUE;
1231 /* Feedback
1232 *---------*/
1233 fprintf(stderr," path: %s\n",the_path);
1234 fprintf(stderr," filename_1: %s\n",filename_1);
1235 fprintf(stderr," filename_2: %s\n",filename_2);
1236 if(*swapbytes) {
1237 fprintf(stderr," Swapbytes: TRUE\n");
1239 else {
1240 fprintf(stderr," Swapbytes: FALSE\n");
1243 err = USERD_set_filenames(filename_1,filename_2,the_path,*swapbytes);
1244 if(err == Z_ERR) {
1245 fprintf(stderr,"Error: Trouble setting the filenames\n");
1246 return(Z_ERR);
1249 return(Z_OK);
1253 /*----------
1254 * time_info
1255 *----------*/
1256 static int
1257 time_info( void )
1259 int i;
1260 int err;
1261 int geom_time_set;
1262 int ts;
1263 float *sol_times;
1264 char ts_desc[Z_BUFL];
1266 fprintf(stderr,"\n-------------- time_info ----------------\n");
1268 #if (defined GT_USERD_API_100)
1270 /* Get the number of timesets
1271 *---------------------------*/
1272 Num_time_sets = USERD_get_number_of_timesets();
1273 fprintf(stderr," number of timesets: %d\n",Num_time_sets);
1274 if(Num_time_sets == 0) {
1275 fprintf(stderr," So, static geometry and variables\n");
1276 return(Z_OK);
1279 /* Get the timeset used for the geometry
1280 *--------------------------------------*/
1281 geom_time_set = USERD_get_geom_timeset_number();
1283 fprintf(stderr," geom timeset number: %d\n",geom_time_set);
1284 if(geom_time_set < 1 && Num_time_sets > 0) {
1285 fprintf(stderr,"Error: timeset numbers must be 1 or greater\n");
1286 fprintf(stderr," (unless Num_time_sets is zero also)\n");
1290 /* For each timeset
1291 *-----------------*/
1292 for(ts=1; ts<=Num_time_sets; ++ts) {
1294 fprintf(stderr," Timeset %d:\n",ts);
1296 /* Get the timeset descriptions
1297 *-----------------------------*/
1298 err = USERD_get_timeset_description(ts,ts_desc);
1299 if(err == Z_ERR) {
1300 fprintf(stderr,"Error: getting timeset description\n");
1301 return(Z_ERR);
1303 else {
1304 fprintf(stderr," description: %s\n",ts_desc);
1307 /* Get the number of time steps
1308 *-----------------------------*/
1309 Num_time_steps = USERD_get_num_of_time_steps(ts);
1310 fprintf(stderr," number of time steps: %d\n",Num_time_steps);
1311 if(Num_time_steps < 1) {
1312 fprintf(stderr," Error: Number of time steps returned: %d\n",Num_time_steps);
1313 fprintf(stderr," (Must be >0 to be okay)\n");
1314 return(Z_ERR);
1318 /* Get the solution times
1319 *-----------------------*/
1320 if(Num_time_steps > 0) {
1321 sol_times = (float *) calloc(Num_time_steps,sizeof(float));
1322 if(sol_times == (float *)NULL) {
1323 fprintf(stderr,"Error: allocating for solution times\n");
1324 return(Z_ERR);
1326 else {
1327 err = USERD_get_sol_times(ts,sol_times);
1328 if(err == Z_ERR) {
1329 fprintf(stderr,"Error: getting solution times\n");
1330 return(Z_ERR);
1332 else {
1333 for(i=0; i<Num_time_steps; ++i) {
1334 fprintf(stderr," At step %d, time = %f\n",i,sol_times[i]);
1338 free(sol_times);
1342 #else
1345 /* Get the number of time steps
1346 *-----------------------------*/
1347 Num_time_steps = USERD_get_number_of_time_steps();
1348 fprintf(stderr," Nnumber of time steps: %d\n",Num_time_steps);
1349 if(Num_time_steps < 1) {
1350 fprintf(stderr," Error: Number of time steps returned: %d\n",Num_time_steps);
1351 fprintf(stderr," (Must be >0 to be okay)\n");
1352 return(Z_ERR);
1356 /* Get the solution times
1357 *-----------------------*/
1358 if(Num_time_steps > 0) {
1359 sol_times = (float *) calloc(Num_time_steps,sizeof(float));
1360 if(sol_times == (float *)NULL) {
1361 fprintf(stderr,"Error: allocating for solution times\n");
1362 return(Z_ERR);
1364 else {
1365 err = USERD_get_solution_times(sol_times);
1366 if(err == Z_ERR) {
1367 fprintf(stderr,"Error: getting solution times\n");
1368 return(Z_ERR);
1370 else {
1371 for(i=0; i<Num_time_steps; ++i) {
1372 fprintf(stderr," At step %d, time = %f\n",i,sol_times[i]);
1376 free(sol_times);
1379 #endif
1381 return(Z_OK);
1386 /*----------------
1387 * part_build_info
1388 *----------------*/
1389 static int
1390 part_build_info(int geom_time_step)
1392 int i, j;
1393 int fn;
1394 int err;
1395 int num_dataset_files;
1396 int geom_time_set;
1397 Z_QFILES *qfiles;
1398 char line1[Z_BUFL];
1399 char line2[Z_BUFL];
1401 int *part_ids;
1402 int *part_types;
1403 int *number_of_nodes;
1404 int **num_elems;
1405 int **ijk_dimensions;
1406 int **iblanking_options;
1407 char **part_descriptions;
1409 int ghosts_in_block;
1411 int *max_num_nodes;
1412 int **max_num_elems;
1413 int **max_ijk_dimensions;
1414 float extents[6];
1417 fprintf(stderr,"\n------------ part_build_info ------------\n");
1419 #if (defined GT_USERD_API_100)
1421 /* Get the timeset used for the geometry
1422 *--------------------------------------*/
1423 geom_time_set = USERD_get_geom_timeset_number();
1425 /* Set the timeset and step - to first step
1426 *-----------------------------------------*/
1428 USERD_set_time_set_and_step(geom_time_set,geom_time_step);
1430 #else
1432 /* Set the time step - to first step
1433 *----------------------------------*/
1434 USERD_set_time_step(geom_time_step);
1436 #endif
1438 /* Get the changing geometry status
1439 *---------------------------------*/
1440 Geom_status = USERD_get_changing_geometry_status();
1441 if(Geom_status == Z_STATIC) {
1442 fprintf(stderr," Geom changing status: Z_STATIC\n");
1444 else if(Geom_status == Z_CHANGE_COORDS) {
1445 fprintf(stderr," Geom changing status: Z_CHANGE_COORDS\n");
1447 else if(Geom_status == Z_CHANGE_CONN) {
1448 fprintf(stderr," Geom changing status: Z_CHANGE_CONN\n");
1450 else {
1451 fprintf(stderr," Invalid Geom changing status!!\n");
1455 /* Get the node label status
1456 *--------------------------*/
1457 Node_labels = USERD_get_node_label_status();
1458 if(Node_labels) {
1459 fprintf(stderr," Node labels will be provided\n");
1461 else {
1462 fprintf(stderr," Node labels will NOT be provided\n");
1465 /* Get the element label status
1466 *-----------------------------*/
1467 Element_labels = USERD_get_element_label_status();
1468 if(Element_labels) {
1469 fprintf(stderr," Element labels will be provided\n");
1471 else {
1472 fprintf(stderr," Element labels will NOT be provided\n");
1475 fprintf(stderr,"\n");
1477 /* Get the number of files in the dataset
1478 *---------------------------------------*/
1479 num_dataset_files = USERD_get_number_of_files_in_dataset();
1480 fprintf(stderr," Number of files in dataset: %d\n",num_dataset_files);
1483 /* Get the dataset query file info
1484 *--------------------------------*/
1485 if(num_dataset_files > 0) {
1487 qfiles = (Z_QFILES *) calloc(num_dataset_files,sizeof(Z_QFILES));
1488 if(qfiles == (Z_QFILES *)NULL) {
1489 fprintf(stderr,"Error: allocating for dataset query files\n");
1490 return(Z_ERR);
1492 else {
1494 for(i=0; i<num_dataset_files; ++i) {
1495 qfiles[i].f_desc = (char **) calloc(10,sizeof(char *));
1496 if(qfiles[i].f_desc == (char **)NULL) {
1497 fprintf(stderr,"Error: allocating for dataset query descrip lines\n");
1498 return(Z_ERR);
1500 else {
1501 for(j=0; j<10; ++j) {
1502 qfiles[i].f_desc[j] = (char *) calloc(Z_MAXFILENP,sizeof(char));
1503 if(qfiles[i].f_desc[j] == (char *)NULL) {
1504 fprintf(stderr,"Error: allocating for dataset query descrip lines\n");
1505 return(Z_ERR);
1511 err = USERD_get_dataset_query_file_info(qfiles);
1512 if(err == Z_OK) {
1513 for(fn=0; fn<num_dataset_files; ++fn) {
1514 fprintf(stderr," For dataset file %d:\n",fn);
1516 fprintf(stderr," name: %s\n",qfiles[fn].name);
1517 fprintf(stderr," size: %d\n",qfiles[fn].sizeb);
1518 fprintf(stderr," time: %s\n",qfiles[fn].timemod);
1519 fprintf(stderr," num desc lines: %d\n",qfiles[fn].num_d_lines);
1520 for(i=0; i<qfiles[fn].num_d_lines; ++i) {
1521 fprintf(stderr," desc line %d: %s\n",i,qfiles[fn].f_desc[i]);
1525 else {
1526 fprintf(stderr,"Error: getting dataset query info\n");
1527 return(Z_ERR);
1531 /* Free allocated memory
1532 *----------------------*/
1533 for(i=0; i<num_dataset_files; ++i) {
1534 for(j=0; j<10; ++j) {
1535 free(qfiles[i].f_desc[j]);
1537 free(qfiles[i].f_desc);
1539 free(qfiles);
1542 fprintf(stderr,"\n-----------------------------------------\n");
1544 #if (defined GT_USERD_API_100)
1546 /* Get the geometry description lines
1547 *-----------------------------------*/
1548 err = USERD_get_descrip_lines(Z_GEOM,0,FALSE,line1,line2);
1549 if(err == Z_OK) {
1550 fprintf(stderr," Geom Desc line1: %s\n",line1);
1551 fprintf(stderr," Geom Desc line2: %s\n",line2);
1553 else {
1554 fprintf(stderr,"Error: getting geom description lines\n");
1555 return(Z_ERR);
1558 #else
1560 /* Get the geometry description lines
1561 *-----------------------------------*/
1562 err = USERD_get_description_lines(Z_GEOM,0,line1,line2);
1563 if(err == Z_OK) {
1564 fprintf(stderr," Geom Desc line1: %s\n",line1);
1565 fprintf(stderr," Geom Desc line2: %s\n",line2);
1567 else {
1568 fprintf(stderr,"Error: getting geom description lines\n");
1569 return(Z_ERR);
1572 #endif
1574 /* Get the number of model parts
1575 *------------------------------*/
1576 Num_parts = USERD_get_number_of_model_parts();
1577 if(Num_parts > 0) {
1578 fprintf(stderr," Number of parts: %d\n",Num_parts);
1580 else {
1581 fprintf(stderr," Problems getting number of parts\n");
1582 return(Z_ERR);
1587 /* Get the gold part build info
1588 *-----------------------------*/
1589 Pbuild = (BUILDINFO *) calloc(Num_parts,sizeof(BUILDINFO));
1590 if(Pbuild == (BUILDINFO *)NULL) {
1591 fprintf(stderr," Problems allocating for Pbuild structure\n");
1592 return(Z_ERR);
1596 part_ids = (int *) calloc(Num_parts,sizeof(int));
1597 if(part_ids == (int *)NULL) {
1598 fprintf(stderr," Problems allocating for part ids\n");
1599 return(Z_ERR);
1602 part_types = (int *) calloc(Num_parts,sizeof(int));
1603 if(part_types == (int *)NULL) {
1604 fprintf(stderr," Problems allocating for part types\n");
1605 return(Z_ERR);
1608 part_descriptions = (char **) calloc(Num_parts,sizeof(char *));
1609 if(part_descriptions == (char **)NULL) {
1610 fprintf(stderr," Problems allocating for part descriptions\n");
1611 return(Z_ERR);
1613 else {
1614 for(i=0; i<Num_parts; ++i) {
1615 part_descriptions[i] = (char *) calloc(Z_BUFL,sizeof(char));
1616 if(part_descriptions[i] == (char *)NULL) {
1617 fprintf(stderr," Problems allocating for part descriptions\n");
1618 return(Z_ERR);
1623 number_of_nodes = (int *) calloc(Num_parts,sizeof(int));
1624 if(number_of_nodes == (int *)NULL) {
1625 fprintf(stderr," Problems allocating for part number of nodes\n");
1626 return(Z_ERR);
1629 num_elems = (int **) calloc(Num_parts,sizeof(int *));
1630 if(num_elems == (int **)NULL) {
1631 fprintf(stderr," Problems allocating for part number of elements\n");
1632 return(Z_ERR);
1634 else {
1635 for(i=0; i<Num_parts; ++i) {
1636 num_elems[i] = (int *) calloc(Z_MAXTYPE,sizeof(int));
1637 if(num_elems[i] == (int *)NULL) {
1638 fprintf(stderr," Problems allocating for part number of elements\n");
1639 return(Z_ERR);
1644 ijk_dimensions = (int **) calloc(Num_parts,sizeof(int *));
1645 if(ijk_dimensions == (int **)NULL) {
1646 fprintf(stderr," Problems allocating for part ijk dimensions\n");
1647 return(Z_ERR);
1649 else {
1651 #if (defined GT_USERD_API_202)
1652 for(i=0; i<Num_parts; ++i) {
1653 ijk_dimensions[i] = (int *) calloc(9,sizeof(int));
1654 if(ijk_dimensions[i] == (int *)NULL) {
1655 fprintf(stderr," Problems allocating for part ijk dimensions\n");
1656 return(Z_ERR);
1658 else {
1659 for(j=0; j<9; ++j) {
1660 ijk_dimensions[i][j] = -1;
1664 #else
1665 for(i=0; i<Num_parts; ++i) {
1666 ijk_dimensions[i] = (int *) calloc(3,sizeof(int));
1667 if(ijk_dimensions[i] == (int *)NULL) {
1668 fprintf(stderr," Problems allocating for part ijk dimensions\n");
1669 return(Z_ERR);
1672 #endif
1675 iblanking_options = (int **) calloc(Num_parts,sizeof(int *));
1676 if(iblanking_options == (int **)NULL) {
1677 fprintf(stderr," Problems allocating for part iblanking options\n");
1678 return(Z_ERR);
1680 else {
1681 for(i=0; i<Num_parts; ++i) {
1682 iblanking_options[i] = (int *) calloc(6,sizeof(int));
1683 if(iblanking_options[i] == (int *)NULL) {
1684 fprintf(stderr," Problems allocating for part iblanking options\n");
1685 return(Z_ERR);
1691 #if (defined GT_USERD_API_100)
1693 err = USERD_get_gold_part_build_info(part_ids,
1694 part_types,
1695 part_descriptions,
1696 number_of_nodes,
1697 num_elems,
1698 ijk_dimensions,
1699 iblanking_options);
1700 #else
1702 err = USERD_get_part_build_info(part_ids,
1703 part_types,
1704 part_descriptions,
1705 num_elems,
1706 ijk_dimensions,
1707 iblanking_options);
1709 #endif
1711 if(err == Z_ERR) {
1712 fprintf(stderr," Problems getting part build info\n");
1713 return(Z_ERR);
1715 else {
1716 for(i=0; i<Num_parts; ++i) {
1717 fprintf(stderr," For part %d:\n",i+1);
1719 fprintf(stderr," part id: %d\n",part_ids[i]);
1720 Pbuild[i].id = part_ids[i];
1722 if(part_types[i] == Z_UNSTRUCTURED) {
1723 fprintf(stderr," part type: Z_UNSTRUCTURED\n");
1725 else if(part_types[i] == Z_STRUCTURED) {
1726 fprintf(stderr," part type: Z_STRUCTURED\n");
1728 else if(part_types[i] == Z_IBLANKED) {
1729 fprintf(stderr," part type: Z_IBLANKED\n");
1731 else {
1732 fprintf(stderr," Invalid part type\n");
1733 return(Z_ERR);
1735 Pbuild[i].type = part_types[i];
1737 fprintf(stderr," part desc: %s\n",part_descriptions[i]);
1738 strncpy(Pbuild[i].desc,part_descriptions[i],Z_BUFL);
1740 #if (defined GT_USERD_API_100)
1741 fprintf(stderr," number of nodes : %d\n",number_of_nodes[i]);
1742 Pbuild[i].nn = number_of_nodes[i];
1743 #else
1744 Pbuild[i].nn = USERD_get_number_of_global_nodes();
1745 #endif
1747 for(j=0; j<Z_MAXTYPE; ++j) {
1748 if(num_elems[i][j] > 0) {
1749 fprintf(stderr," # %s elements: %d\n",
1750 Elem_info[j].name,num_elems[i][j]);
1751 Pbuild[i].ne[j] = num_elems[i][j];
1755 if(part_types[i] != Z_UNSTRUCTURED) {
1757 /* For this checker, we will place the following in the
1758 * Pbuild[].ne[] structure:
1760 * Note this is can be used for block size whether ranges or not
1761 * -------------------------------------------------------------
1762 * Pbuild[].ne[0] = i dim of current block (to the range selected)
1763 * Pbuild[].ne[1] = j dim of current block (to the range selected)
1764 * Pbuild[].ne[2] = k dim of current block (to the range selected)
1766 * Thus if ranges:
1767 * ---------------
1768 * Pbuild[].ne[3] = i min range (-1 indicates no ranges)
1769 * Pbuild[].ne[4] = i max range
1770 * Pbuild[].ne[5] = i min range
1771 * Pbuild[].ne[6] = i max range
1772 * Pbuild[].ne[7] = i min range
1773 * Pbuild[].ne[8] = i max range
1775 * Pbuild[].ne[9] = i dim of total block (if ranges)
1776 * Pbuild[].ne[10] = j dim of total block (if ranges)
1777 * Pbuild[].ne[11] = k dim of total block (if ranges)
1779 * What comes back from the api is:
1780 * --------------------------------
1781 * before 2.03 (no ranges)
1782 * -----------------------
1783 * ijk_dimensions[][0] = i dim of block
1784 * ijk_dimensions[][1] = j dim of block
1785 * ijk_dimensions[][2] = k dim of block
1787 * at 2.03 (if no ranges)
1788 * -------
1789 * ijk_dimensions[][0] = i dim of block
1790 * ijk_dimensions[][1] = j dim of block
1791 * ijk_dimensions[][2] = k dim of block
1792 * ijk_dimensions[][3] = -1
1794 * at 2.03 (if ranges)
1795 * -------
1796 * ijk_dimensions[][0] = i dim of total block
1797 * ijk_dimensions[][1] = j dim of total block
1798 * ijk_dimensions[][2] = k dim of total block
1799 * ijk_dimensions[][3] = i min range
1800 * ijk_dimensions[][4] = i max range
1801 * ijk_dimensions[][5] = j min range
1802 * ijk_dimensions[][6] = j max range
1803 * ijk_dimensions[][7] = k min range
1804 * ijk_dimensions[][8] = k max range
1805 *--------------------------------------------------------------*/
1807 #if (defined GT_USERD_API_202)
1808 if(ijk_dimensions[i][3] == -1) {
1809 fprintf(stderr," ijk_dimensions: %d %d %d\n",
1810 ijk_dimensions[i][0],
1811 ijk_dimensions[i][1],
1812 ijk_dimensions[i][2]);
1813 Pbuild[i].ne[0] = ijk_dimensions[i][0];
1814 Pbuild[i].ne[1] = ijk_dimensions[i][1];
1815 Pbuild[i].ne[2] = ijk_dimensions[i][2];
1816 Pbuild[i].ne[3] = ijk_dimensions[i][3];
1818 else {
1820 /* If empty part
1821 *--------------*/
1822 if(ijk_dimensions[i][0] == 0 &&
1823 ijk_dimensions[i][1] == 0 &&
1824 ijk_dimensions[i][2] == 0) {
1825 fprintf(stderr," ijk_dimensions: %d %d %d\n",
1826 ijk_dimensions[i][0],
1827 ijk_dimensions[i][1],
1828 ijk_dimensions[i][2]);
1829 Pbuild[i].ne[0] = ijk_dimensions[i][0];
1830 Pbuild[i].ne[1] = ijk_dimensions[i][1];
1831 Pbuild[i].ne[2] = ijk_dimensions[i][2];
1832 Pbuild[i].ne[3] = -1;
1835 /* range part
1836 *-----------*/
1837 else {
1838 Pbuild[i].ne[0] = ijk_dimensions[i][4] - ijk_dimensions[i][3] + 1;
1839 Pbuild[i].ne[1] = ijk_dimensions[i][6] - ijk_dimensions[i][5] + 1;
1840 Pbuild[i].ne[2] = ijk_dimensions[i][8] - ijk_dimensions[i][7] + 1;
1842 Pbuild[i].ne[3] = ijk_dimensions[i][3];
1843 Pbuild[i].ne[4] = ijk_dimensions[i][4];
1844 Pbuild[i].ne[5] = ijk_dimensions[i][5];
1845 Pbuild[i].ne[6] = ijk_dimensions[i][6];
1846 Pbuild[i].ne[7] = ijk_dimensions[i][7];
1847 Pbuild[i].ne[8] = ijk_dimensions[i][8];
1849 Pbuild[i].ne[9] = ijk_dimensions[i][0];
1850 Pbuild[i].ne[10] = ijk_dimensions[i][1];
1851 Pbuild[i].ne[11] = ijk_dimensions[i][2];
1853 fprintf(stderr," Part has ranges:\n");
1854 fprintf(stderr," ijk dimensions of total block: %d %d %d\n",
1855 Pbuild[i].ne[9],
1856 Pbuild[i].ne[10],
1857 Pbuild[i].ne[11]);
1858 fprintf(stderr," i range: %d to %d\n",
1859 Pbuild[i].ne[3],
1860 Pbuild[i].ne[4]);
1861 fprintf(stderr," j range: %d to %d\n",
1862 Pbuild[i].ne[5],
1863 Pbuild[i].ne[6]);
1864 fprintf(stderr," k range: %d to %d\n",
1865 Pbuild[i].ne[7],
1866 Pbuild[i].ne[8]);
1867 fprintf(stderr," ijk dimensions of range portion: %d %d %d\n",
1868 Pbuild[i].ne[0],
1869 Pbuild[i].ne[1],
1870 Pbuild[i].ne[2]);
1873 #else
1874 fprintf(stderr," ijk_dimensions: %d %d %d\n",
1875 ijk_dimensions[i][0],
1876 ijk_dimensions[i][1],
1877 ijk_dimensions[i][2]);
1878 Pbuild[i].ne[0] = ijk_dimensions[i][0];
1879 Pbuild[i].ne[1] = ijk_dimensions[i][1];
1880 Pbuild[i].ne[2] = ijk_dimensions[i][2];
1881 Pbuild[i].ne[3] = -1;
1882 #endif
1883 if(part_types[i] == Z_IBLANKED) {
1884 fprintf(stderr," Ibanking options on:\n");
1885 if(iblanking_options[i][Z_EXT]) {
1886 fprintf(stderr," Z_EXT\n");
1888 if(iblanking_options[i][Z_INT]) {
1889 fprintf(stderr," Z_INT\n");
1891 if(iblanking_options[i][Z_BND]) {
1892 fprintf(stderr," Z_BND\n");
1894 if(iblanking_options[i][Z_INTBND]) {
1895 fprintf(stderr," Z_INTBND\n");
1897 if(iblanking_options[i][Z_SYM]) {
1898 fprintf(stderr," Z_SYM\n");
1906 #if (defined GT_USERD_API_200)
1908 /* Get ghosts in model flag
1909 *-------------------------*/
1910 Ghosts_in_model = USERD_get_ghosts_in_model_flag();
1911 if(Ghosts_in_model) {
1912 fprintf(stderr," Ghosts in Model: TRUE\n");
1914 else {
1915 fprintf(stderr," Ghosts in Model: FALSE\n");
1918 /* Get ghosts in block flag - if needed
1919 *-------------------------------------*/
1920 for(i=1; i<=Num_parts; ++i) {
1921 if(part_types[i-1] != Z_UNSTRUCTURED && Ghosts_in_model) {
1922 ghosts_in_block = USERD_get_ghosts_in_block_flag(i);
1923 Pbuild[i-1].ghosts = ghosts_in_block;
1924 if(ghosts_in_block) {
1925 fprintf(stderr," Ghosts in block part %d: TRUE\n",i);
1927 else {
1928 fprintf(stderr," Ghosts in block part %d: FALSE\n",i);
1933 #endif
1936 #if (defined GT_USERD_API_100)
1938 /* Get maxsize info
1939 *-----------------*/
1940 max_num_nodes = (int *) calloc(Num_parts,sizeof(int));
1941 if(max_num_nodes == (int *)NULL) {
1942 fprintf(stderr," Problems allocating for part max num of nodes\n");
1943 return(Z_ERR);
1946 max_num_elems = (int **) calloc(Num_parts,sizeof(int *));
1947 if(max_num_elems == (int **)NULL) {
1948 fprintf(stderr," Problems allocating for part max num of elements\n");
1949 return(Z_ERR);
1951 else {
1952 for(i=0; i<Num_parts; ++i) {
1953 max_num_elems[i] = (int *) calloc(Z_MAXTYPE,sizeof(int));
1954 if(max_num_elems[i] == (int *)NULL) {
1955 fprintf(stderr," Problems allocating for part max_num of elements\n");
1956 return(Z_ERR);
1961 max_ijk_dimensions = (int **) calloc(Num_parts,sizeof(int *));
1962 if(max_ijk_dimensions == (int **)NULL) {
1963 fprintf(stderr," Problems allocating for part max ijk dimensions\n");
1964 return(Z_ERR);
1966 else {
1967 for(i=0; i<Num_parts; ++i) {
1968 max_ijk_dimensions[i] = (int *) calloc(3,sizeof(int));
1969 if(max_ijk_dimensions[i] == (int *)NULL) {
1970 fprintf(stderr," Problems allocating for part max ijk dimensions\n");
1971 return(Z_ERR);
1976 err = USERD_get_maxsize_info(max_num_nodes,
1977 max_num_elems,
1978 max_ijk_dimensions);
1979 if(err == Z_ERR) {
1980 fprintf(stderr," No maxsize info provided (or error getting them)\n");
1982 else {
1984 for(i=0; i<Num_parts; ++i) {
1985 fprintf(stderr," For part %d:\n",i+1);
1987 fprintf(stderr," max number of nodes : %d\n",max_num_nodes[i]);
1989 for(j=0; j<Z_MAXTYPE; ++j) {
1990 if(max_num_elems[i][j] > 0) {
1991 fprintf(stderr," max # %s elems: %d\n",
1992 Elem_info[j].name,max_num_elems[i][j]);
1996 if(part_types[i] != Z_UNSTRUCTURED) {
1997 fprintf(stderr," max_ijk_dimensions: %d %d %d\n",
1998 max_ijk_dimensions[i][0],
1999 max_ijk_dimensions[i][1],
2000 max_ijk_dimensions[i][2]);
2005 /* Get model extents - if given
2006 *-----------------------------*/
2007 err = USERD_get_model_extents(extents);
2008 if(err == Z_ERR) {
2009 fprintf(stderr," No extents given\n");
2011 else {
2012 fprintf(stderr," Min x: %g\n",extents[0]);
2013 fprintf(stderr," Max x: %g\n",extents[1]);
2014 fprintf(stderr," Min y: %g\n",extents[2]);
2015 fprintf(stderr," Max y: %g\n",extents[3]);
2016 fprintf(stderr," Min z: %g\n",extents[4]);
2017 fprintf(stderr," Max z: %g\n",extents[5]);
2020 #endif
2022 /* Free the allocated memory
2023 *--------------------------*/
2024 free(part_ids);
2025 free(part_types);
2026 free(number_of_nodes);
2028 for(i=0; i<Num_parts; ++i) {
2029 free(ijk_dimensions[i]);
2030 free(num_elems[i]);
2031 free(part_descriptions[i]);
2033 free(ijk_dimensions);
2034 free(num_elems);
2035 free(iblanking_options);
2036 free(part_descriptions);
2038 #if (defined GT_USERD_API_100)
2039 for(i=0; i<Num_parts; ++i) {
2040 free(max_ijk_dimensions[i]);
2041 free(max_num_elems[i]);
2043 free(max_num_nodes);
2044 free(max_num_elems);
2045 free(max_ijk_dimensions);
2047 #endif
2049 return(Z_OK);
2053 /*--------------
2054 * variable_info
2055 *--------------*/
2056 static int
2057 variable_info( void )
2059 int i,j;
2060 int err;
2062 char **var_description;
2063 char **var_filename;
2064 int *var_type;
2065 int *var_classify;
2066 int *var_complex;
2067 char **var_ifilename;
2068 float *var_freq;
2069 int *var_contran;
2070 int *var_timeset;
2073 fprintf(stderr,"\n------------ variable_info --------------\n");
2075 /* Get the number of variables
2076 *----------------------------*/
2077 Num_vars = USERD_get_number_of_variables();
2078 if(Num_vars < 0) {
2079 fprintf(stderr,"Error: getting the number of variables\n");
2081 else {
2082 fprintf(stderr," Number of variables: %d\n",Num_vars);
2086 /* Get the gold variable info
2087 *---------------------------*/
2088 Varinfo = (VARINFO *) calloc(Num_vars,sizeof(VARINFO));
2089 if(Varinfo == (VARINFO *)NULL) {
2090 fprintf(stderr," Problems allocating for Varinfo structure\n");
2091 return(Z_ERR);
2095 var_description = (char **) calloc(Num_vars,sizeof(char *));
2096 if(var_description == (char **)NULL) {
2097 fprintf(stderr," Problems allocating for var description\n");
2098 return(Z_ERR);
2100 else {
2101 for(i=0; i<Num_vars; ++i) {
2102 var_description[i] = (char *) calloc(Z_BUFL,sizeof(char));
2103 if(var_description[i] == (char *)NULL) {
2104 fprintf(stderr," Problems allocating for var description\n");
2105 return(Z_ERR);
2110 var_filename = (char **) calloc(Num_vars,sizeof(char *));
2111 if(var_filename == (char **)NULL) {
2112 fprintf(stderr," Problems allocating for var filename\n");
2113 return(Z_ERR);
2115 else {
2116 for(i=0; i<Num_vars; ++i) {
2117 var_filename[i] = (char *) calloc(Z_BUFL,sizeof(char));
2118 if(var_filename[i] == (char *)NULL) {
2119 fprintf(stderr," Problems allocating for var filename\n");
2120 return(Z_ERR);
2125 var_type = (int *) calloc(Num_vars,sizeof(int));
2126 if(var_type == (int *)NULL) {
2127 fprintf(stderr," Problems allocating for var type\n");
2128 return(Z_ERR);
2131 var_classify = (int *) calloc(Num_vars,sizeof(int));
2132 if(var_classify == (int *)NULL) {
2133 fprintf(stderr," Problems allocating for var classify\n");
2134 return(Z_ERR);
2137 var_complex = (int *) calloc(Num_vars,sizeof(int));
2138 if(var_complex == (int *)NULL) {
2139 fprintf(stderr," Problems allocating for var complex\n");
2140 return(Z_ERR);
2144 var_ifilename = (char **) calloc(Num_vars,sizeof(char *));
2145 if(var_ifilename == (char **)NULL) {
2146 fprintf(stderr," Problems allocating for var ifilename\n");
2147 return(Z_ERR);
2149 else {
2150 for(i=0; i<Num_vars; ++i) {
2151 var_ifilename[i] = (char *) calloc(Z_BUFL,sizeof(char));
2152 if(var_ifilename[i] == (char *)NULL) {
2153 fprintf(stderr," Problems allocating for var ifilename\n");
2154 return(Z_ERR);
2159 var_freq = (float *) calloc(Num_vars,sizeof(float));
2160 if(var_freq == (float *)NULL) {
2161 fprintf(stderr," Problems allocating for var freq\n");
2162 return(Z_ERR);
2165 var_contran = (int *) calloc(Num_vars,sizeof(int));
2166 if(var_contran == (int *)NULL) {
2167 fprintf(stderr," Problems allocating for var contran\n");
2168 return(Z_ERR);
2171 var_timeset = (int *) calloc(Num_vars,sizeof(int));
2172 if(var_timeset == (int *)NULL) {
2173 fprintf(stderr," Problems allocating for var timeset\n");
2174 return(Z_ERR);
2177 #if (defined GT_USERD_API_100)
2179 err = USERD_get_gold_variable_info(var_description,
2180 var_filename,
2181 var_type,
2182 var_classify,
2183 var_complex,
2184 var_ifilename,
2185 var_freq,
2186 var_contran,
2187 var_timeset);
2188 #else
2190 err = USERD_get_variable_info(var_description,
2191 var_filename,
2192 var_type,
2193 var_classify);
2195 #endif
2197 if(err == Z_ERR) {
2198 fprintf(stderr,"Error: getting variable info\n");
2200 else {
2201 for(i=0; i<Num_vars; ++i) {
2203 /* Loading the global
2204 * (for use in other routines)
2205 *----------------------------*/
2206 strncpy(Varinfo[i].description,var_description[i],Z_BUFL);
2207 strncpy(Varinfo[i].filename,var_filename[i],Z_BUFL);
2208 strncpy(Varinfo[i].ifilename,var_ifilename[i],Z_BUFL);
2209 Varinfo[i].type = var_type[i];
2210 Varinfo[i].classify = var_classify[i];
2211 Varinfo[i].complex = var_complex[i];
2212 Varinfo[i].freq = var_freq[i];
2213 Varinfo[i].contran = var_contran[i];
2214 Varinfo[i].timeset = var_timeset[i];
2216 /* Echo some feedback
2217 *-------------------*/
2218 fprintf(stderr," For Variable %d:\n",i+1);
2220 fprintf(stderr," var desc: %s\n",var_description[i]);
2221 fprintf(stderr," var filename: %s\n",var_filename[i]);
2223 #if (defined GT_USERD_API_100)
2224 if(var_complex[i]) {
2225 fprintf(stderr," var complex: TRUE\n");
2226 fprintf(stderr," var ifilename: %s\n",var_ifilename[i]);
2227 fprintf(stderr," var freq: %g\n",var_freq[i]);
2229 else {
2230 fprintf(stderr," var complex: FALSE\n");
2232 #endif
2234 if(var_type[i] == Z_CONSTANT) {
2235 fprintf(stderr," var type: Z_CONSTANT\n");
2237 #if (defined GT_USERD_API_100)
2238 if(var_contran[i]) {
2239 fprintf(stderr," var contran: TRUE\n");
2241 else {
2242 fprintf(stderr," var contran: FALSE\n");
2244 #endif
2247 else if(var_type[i] == Z_SCALAR) {
2248 fprintf(stderr," var type: Z_SCALAR\n");
2250 else if(var_type[i] == Z_VECTOR) {
2251 fprintf(stderr," var type: Z_VECTOR\n");
2253 else if(var_type[i] == Z_TENSOR) {
2254 fprintf(stderr," var type: Z_TENSOR\n");
2256 else if(var_type[i] == Z_TENSOR9) {
2257 fprintf(stderr," var type: Z_TENSOR9\n");
2259 else {
2260 fprintf(stderr," Invalid var type\n");
2261 return(Z_ERR);
2264 if(var_classify[i] == Z_PER_NODE) {
2265 fprintf(stderr," var classify: Z_PER_NODE\n");
2267 else if(var_classify[i] == Z_PER_ELEM) {
2268 fprintf(stderr," var classify: Z_PER_ELEM\n");
2270 else if(var_classify[i] != Z_CONSTANT) {
2271 fprintf(stderr," Invalid var classify\n");
2272 return(Z_ERR);
2275 #if (defined GT_USERD_API_100)
2276 fprintf(stderr," var timeset: %d\n",var_timeset[i]);
2277 #endif
2281 /* Free the allocated memory
2282 *--------------------------*/
2283 for(i=0; i<Num_vars; ++i) {
2284 free(var_description[i]);
2285 free(var_filename[i]);
2286 free(var_ifilename[i]);
2288 free(var_description);
2289 free(var_filename);
2290 free(var_ifilename);
2291 free(var_type);
2292 free(var_classify);
2293 free(var_complex);
2294 free(var_freq);
2295 free(var_contran);
2296 free(var_timeset);
2298 return(Z_OK);
2302 #if (defined GT_USERD_API_100)
2303 /*------------------
2304 * gold_part_builder
2305 *------------------*/
2306 static int
2307 gold_part_builder(int geom_time_step)
2309 int i, j, k, jj, kk;
2310 int err;
2311 int geom_timeset;
2312 int p, pn;
2313 int et, ne;
2314 int *elemids;
2315 int **conns;
2316 int nn;
2317 int comp;
2318 int bdim[3];
2319 int ib[5];
2320 int num_ghosts;
2321 int num_dims;
2322 int cell_type;
2323 float mm[6];
2324 float **coords;
2325 int *nodeids;
2326 int *iblanking;
2327 int *ghost_flag;
2328 short *parent_type;
2329 int *parent_num;
2330 int num_elems[Z_MAXTYPE];
2331 CRD *crds;
2332 int bd1,bd2,bd3;
2333 int empty_part;
2334 int *pdata;
2335 int nsid_len;
2336 int *nsid_con;
2337 int nface_len;
2338 int *nface_con;
2339 int npf_len;
2340 int *npf_con;
2341 int maxcheck;
2342 int num_failed = 0;
2343 int *fail_flags = (int *) NULL;
2345 fprintf(stderr,"\n------------- part_builder --------------\n");
2347 if(Num_time_sets > 0) {
2348 /* Get the timeset used for the geometry
2349 *--------------------------------------*/
2350 geom_timeset = USERD_get_geom_timeset_number();
2352 /* Get the number of time steps for this timeset
2353 *----------------------------------------------*/
2354 Num_time_steps = USERD_get_num_of_time_steps(geom_timeset);
2355 if(Num_time_steps < 1) {
2356 fprintf(stderr," Error: Number of time steps returned: %d\n",Num_time_steps);
2357 fprintf(stderr," (Must be >0 to be okay)\n");
2358 return(Z_ERR);
2360 if(geom_time_step > (Num_time_steps - 1)) {
2361 geom_time_step = Num_time_steps - 1;
2364 /* Set the timeset and step - to first step by default, but
2365 * can set it at others using -gts command argument
2366 *---------------------------------------------------------*/
2367 USERD_set_time_set_and_step(geom_timeset,geom_time_step);
2369 fprintf(stderr," Using timeset: %d (step range is %d through %d)\n",
2370 geom_timeset,0,Num_time_steps-1);
2371 fprintf(stderr," Using time step: %d\n",geom_time_step);
2374 for(p=0; p<Num_parts; ++p) {
2375 pn = p+1;
2377 fprintf(stderr,"\n\n----------------------------------------");
2378 fprintf(stderr," Part %d:\n",pn);
2380 /*-----------------------
2381 * For unstructured parts
2382 *-----------------------*/
2383 if(Pbuild[p].type == Z_UNSTRUCTURED) {
2385 for(et=0; et<Z_MAXTYPE; ++et) {
2386 ne = Pbuild[p].ne[et];
2388 if(ne > 0) {
2390 pdata = (int *)calloc(ne*Elem_info[et].con_len,sizeof(int));
2391 if(pdata == (int *) NULL) {
2392 fprintf(stderr,"Error: allocating conns array\n");
2393 return(Z_ERR);
2395 else {
2396 conns = (int **) calloc(ne,sizeof(int *));
2397 if(conns == (int **) NULL) {
2398 fprintf(stderr,"Error: allocating conns array\n");
2399 return(Z_ERR);
2401 for(i=0; i<ne; ++i) {
2402 conns[i] = pdata;
2403 pdata += Elem_info[et].con_len;
2408 /* Get the elements
2409 *-----------------*/
2410 err = USERD_get_part_elements_by_type(pn,et,conns);
2411 if(err == Z_ERR) {
2412 fprintf(stderr,"Error: getting element connectivities\n");
2413 return(Z_ERR);
2416 if(Element_labels) {
2417 elemids = (int *) calloc(ne,sizeof(int));
2418 if(elemids == (int *) NULL) {
2419 fprintf(stderr,"Error: allocating elemids array\n");
2420 return(Z_ERR);
2424 /* Get the element ids - if any
2425 *-----------------------------*/
2426 if(Element_labels) {
2427 err = USERD_get_part_element_ids_by_type(pn,et,elemids);
2428 if(err == Z_ERR) {
2429 fprintf(stderr,"Error: getting element ids\n");
2430 return(Z_ERR);
2434 /* Echo "some" info
2435 *-----------------*/
2437 #if (defined GT_USERD_API_202)
2439 maxcheck = Z_NSIDED;
2441 /* Nsided elements, if any
2442 *------------------------*/
2443 if(et == Z_NSIDED ||
2444 et == Z_G_NSIDED) {
2446 nsid_len = 0;
2447 for(i=0; i<ne; ++i) {
2448 nsid_len += conns[i][0];
2451 nsid_con = (int *) calloc(nsid_len,sizeof(int));
2452 if(nsid_con == (int *) NULL) {
2453 fprintf(stderr,"Error: allocating nsided conn array\n");
2454 return(Z_ERR);
2457 err = USERD_get_nsided_conn(pn,nsid_con);
2458 if(err == Z_ERR) {
2459 fprintf(stderr,"Error: getting nsided conn array\n");
2460 return(Z_ERR);
2463 /* First element of the type
2464 *--------------------------*/
2465 i = 0;
2466 fprintf(stderr," %s Element %d of %d:\n",Elem_info[et].name,i+1,ne);
2467 if(Element_labels) {
2468 fprintf(stderr," id: %d\n",elemids[i]);
2470 fprintf(stderr," connectivity:");
2471 for(j=0; j<conns[i][0]; ++j) {
2472 fprintf(stderr," %d",nsid_con[j]);
2474 fprintf(stderr,"\n");
2476 /* Last element of the type
2477 *-------------------------*/
2478 i = ne - 1;
2479 if(i > 0) {
2480 fprintf(stderr," %s Element %d of %d:\n",Elem_info[et].name,i+1,ne);
2481 if(Element_labels) {
2482 fprintf(stderr," id: %d\n",elemids[i]);
2484 fprintf(stderr," connectivity:");
2486 for(j=nsid_len-conns[i][0]; j<nsid_len; ++j) {
2487 fprintf(stderr," %d",nsid_con[j]);
2489 fprintf(stderr,"\n");
2493 /* Nfaced elements if any
2494 *-----------------------*/
2495 if(et == Z_NFACED ||
2496 et == Z_G_NFACED) {
2498 nface_len = 0;
2499 for(i=0; i<ne; ++i) {
2500 nface_len += conns[i][0];
2503 nface_con = (int *) calloc(nface_len,sizeof(int));
2504 if(nface_con == (int *) NULL) {
2505 fprintf(stderr,"Error: allocating nfaced face array\n");
2506 return(Z_ERR);
2509 err = USERD_get_nfaced_nodes_per_face(pn,nface_con);
2510 if(err == Z_ERR) {
2511 fprintf(stderr,"Error: getting nfaced face array array\n");
2512 return(Z_ERR);
2515 npf_len = 0;
2516 for(i=0; i<nface_len; ++i) {
2517 npf_len += nface_con[i];
2520 npf_con = (int *) calloc(npf_len,sizeof(int));
2521 if(npf_con == (int *) NULL) {
2522 fprintf(stderr,"Error: allocating nfaced npf array\n");
2523 return(Z_ERR);
2526 err = USERD_get_nfaced_conn(pn,npf_con);
2527 if(err == Z_ERR) {
2528 fprintf(stderr,"Error: getting nfaced conn array\n");
2529 return(Z_ERR);
2532 /* First element of the type
2533 *--------------------------*/
2534 jj = 0;
2535 kk = 0;
2536 for(i=0; i<ne; ++i) {
2538 if(i == 0 ||
2539 i == ne-1) {
2540 fprintf(stderr," %s Element %d of %d:\n",Elem_info[et].name,
2541 i+1,ne);
2542 if(Element_labels) {
2543 fprintf(stderr," id: %d\n",elemids[i]);
2545 for(j=0; j<conns[i][0]; ++j) {
2546 fprintf(stderr," face %d connectivity:",j+1);
2547 for(k=0; k<nface_con[jj]; ++k) {
2548 fprintf(stderr," %d",npf_con[kk]);
2549 ++kk;
2551 fprintf(stderr,"\n");
2552 ++jj;
2555 else {
2556 for(j=0; j<conns[i][0]; ++j) {
2557 for(k=0; k<nface_con[jj]; ++k) {
2558 ++kk;
2560 ++jj;
2565 #else
2567 maxcheck = Z_MAXTYPE;
2569 #endif
2571 /* Regular elements
2572 *-----------------*/
2573 if(et < maxcheck) {
2575 /* First element of the type
2576 *--------------------------*/
2577 i = 0;
2578 fprintf(stderr," %s Element %d of %d:\n",Elem_info[et].name,i+1,ne);
2579 if(Element_labels) {
2580 fprintf(stderr," id: %d\n",elemids[i]);
2582 fprintf(stderr," connectivity:");
2583 for(j=0; j<Elem_info[et].con_len; ++j) {
2584 fprintf(stderr," %d",conns[i][j]);
2586 fprintf(stderr,"\n");
2588 /* check the connectivity for negative numbers
2589 * -------------------------------------------*/
2590 #if defined GT_USERD_API_100
2591 for (i=0;i<ne;i++){
2592 for(j=0; j<Elem_info[et].con_len; ++j) {
2593 /* ---------- uncomment to print out connectivity values ---------- */
2594 /* fprintf(stderr," %d",conns[i][j]); */
2595 if (conns[i][j] <= 0 || conns[i][j] > Pbuild[p].nn ) {
2596 fprintf(stderr,"\n****************************\n");
2597 fprintf(stderr,"Connectivity value out of bounds: \n");
2598 fprintf(stderr,"Either less than zero or greater than \n");
2599 fprintf(stderr," number of nodes in part!! \n");
2600 fprintf(stderr,"i = %d j = %d conns[i][j] = %d \n",i,j,conns[i][j]);
2601 fprintf(stderr,"****************************\n");
2604 /* ---------- uncomment to print out connectivity values ---------- */
2605 /* fprintf(stderr,"\n"); */
2607 #endif
2608 /* Last element of the type
2609 *-------------------------*/
2610 i = ne - 1;
2611 if(i > 0) {
2612 fprintf(stderr," %s Element %d of %d:\n",Elem_info[et].name,i+1,ne);
2613 if(Element_labels) {
2614 fprintf(stderr," id: %d\n",elemids[i]);
2616 fprintf(stderr," connectivity:");
2617 for(j=0; j<Elem_info[et].con_len; ++j) {
2618 fprintf(stderr," %d",conns[i][j]);
2620 fprintf(stderr,"\n");
2624 /* Free the allocated memory
2625 *--------------------------*/
2626 if(NULL != conns) {
2627 if(NULL != *conns) {
2628 free(*conns);
2629 *conns = NULL;
2631 free(conns);
2632 conns = NULL;
2635 if(Element_labels) {
2636 free(elemids);
2641 /* Get the coords
2642 *---------------*/
2643 nn = Pbuild[p].nn;
2645 if(nn > 0) {
2647 coords = (float **) calloc(3,sizeof(float *));
2648 if(coords == (float **) NULL) {
2649 fprintf(stderr,"Error: allocating coords array\n");
2650 return(Z_ERR);
2652 else {
2653 for(i=0; i<3; ++i) {
2654 coords[i] = (float *) calloc((nn+1),sizeof(float));
2655 if(coords[i] == (float *) NULL) {
2656 fprintf(stderr,"Error: allocating coords array\n");
2657 return(Z_ERR);
2662 if(Node_labels) {
2663 nodeids = (int *) calloc((nn+1),sizeof(int));
2664 if(nodeids == (int *) NULL) {
2665 fprintf(stderr,"Error: allocating nodeids array\n");
2666 return(Z_ERR);
2671 err = USERD_get_part_coords(pn,coords);
2672 if(err == Z_ERR) {
2673 fprintf(stderr,"Error: getting unstructured coords\n");
2674 return(Z_ERR);
2677 if(Node_labels) {
2678 err = USERD_get_part_node_ids(pn,nodeids);
2679 if(err == Z_ERR) {
2680 fprintf(stderr,"Error: getting nodeids\n");
2681 return(Z_ERR);
2685 /* Echo "some" info
2686 *-----------------*/
2688 /* First node
2689 *-----------*/
2690 i = 1;
2691 fprintf(stderr," Node %d of %d:\n",i,nn);
2692 if(Node_labels) {
2693 fprintf(stderr," id: %d\n",nodeids[i]);
2695 fprintf(stderr," x y z coordinates: %g %g %g\n",
2696 coords[0][i], coords[1][i], coords[2][i]);
2697 mm[0] = mm[1] = coords[0][i];
2698 mm[2] = mm[3] = coords[1][i];
2699 mm[4] = mm[5] = coords[2][i];
2702 /* Last node
2703 *----------*/
2704 i = nn;
2705 if(i > 1) {
2706 fprintf(stderr," Node %d of %d:\n",i,nn);
2707 if(Node_labels) {
2708 fprintf(stderr," id: %d\n",nodeids[i]);
2710 fprintf(stderr," x y z coordinates: %g %g %g\n",
2711 coords[0][i], coords[1][i], coords[2][i]);
2714 /* Min and max coordinate values
2715 *------------------------------*/
2716 for(i=2; i<=nn; ++i) {
2717 if(coords[0][i] < mm[0]) {
2718 mm[0] = coords[0][i];
2720 if(coords[0][i] > mm[1]) {
2721 mm[1] = coords[0][i];
2723 if(coords[1][i] < mm[2]) {
2724 mm[2] = coords[1][i];
2726 if(coords[1][i] > mm[3]) {
2727 mm[3] = coords[1][i];
2729 if(coords[2][i] < mm[4]) {
2730 mm[4] = coords[2][i];
2732 if(coords[2][i] > mm[5]) {
2733 mm[5] = coords[2][i];
2737 fprintf(stderr," Coordinate ranges:\n");
2738 fprintf(stderr," min x: %g\n",mm[0]);
2739 fprintf(stderr," max x: %g\n",mm[1]);
2740 fprintf(stderr," min y: %g\n",mm[2]);
2741 fprintf(stderr," max y: %g\n",mm[3]);
2742 fprintf(stderr," min z: %g\n",mm[4]);
2743 fprintf(stderr," max z: %g\n",mm[5]);
2746 /* Free the allocated memory
2747 *--------------------------*/
2748 for(i=0; i<3; ++i) {
2749 free(coords[i]);
2751 free(coords);
2752 if(Node_labels) {
2753 free(nodeids);
2759 /*---------------------
2760 * For structured parts
2761 *---------------------*/
2762 else {
2764 empty_part = FALSE;
2765 if(Pbuild[p].ne[0] == 0 &&
2766 Pbuild[p].ne[1] == 0 &&
2767 Pbuild[p].ne[2] == 0) {
2768 empty_part = TRUE;
2771 if(!empty_part) {
2773 /* Get the block coords
2774 *---------------------*/
2775 for(comp=0; comp<3; ++comp) {
2776 if(Pbuild[p].ne[comp] < 1) {
2777 bdim[comp] = 1;
2779 else {
2780 bdim[comp] = Pbuild[p].ne[comp];
2783 nn = bdim[0] * bdim[1] * bdim[2];
2785 bd1 = bdim[0]-1;
2786 if(bd1 < 1) {
2787 bd1 = 1;
2789 bd2 = bdim[1]-1;
2790 if(bd2 < 1) {
2791 bd2 = 1;
2793 bd3 = bdim[2]-1;
2794 if(bd3 < 1) {
2795 bd3 = 1;
2797 ne = bd1 * bd2 * bd3;
2799 /* Determine cell type
2800 *--------------------*/
2801 num_dims = 3;
2802 for(i=0; i<3; ++i) {
2803 if(bdim[i] == 1) {
2804 --num_dims;
2807 if(num_dims == 3) {
2808 cell_type = Z_HEX08;
2810 else if(num_dims == 2) {
2811 cell_type = Z_QUA04;
2813 else {
2814 cell_type = Z_BAR02;
2817 coords = (float **) calloc(num_dims,sizeof(float *));
2818 if(coords == (float **) NULL) {
2819 fprintf(stderr,"Error: allocating coords array\n");
2820 return(Z_ERR);
2822 else {
2823 for(i=0; i<num_dims; ++i) {
2824 coords[i] = (float *) calloc(nn,sizeof(float));
2825 if(coords[i] == (float *) NULL) {
2826 fprintf(stderr,"Error: allocating coords array\n");
2827 return(Z_ERR);
2832 /* Get the coords
2833 *---------------*/
2834 for(comp=0; comp<num_dims; ++comp) {
2835 err = USERD_get_block_coords_by_component(pn,comp,coords[comp]);
2836 if(err == Z_ERR) {
2837 fprintf(stderr,"Error: getting block coords\n");
2838 return(Z_ERR);
2843 #if (defined GT_USERD_API_200)
2845 if(Node_labels) {
2846 nodeids = (int *) calloc(nn,sizeof(int));
2847 if(nodeids == (int *) NULL) {
2848 fprintf(stderr,"Error: allocating nodeids array\n");
2849 return(Z_ERR);
2852 /* Get the node ids - if any
2853 *--------------------------*/
2854 if(Node_labels) {
2855 err = USERD_get_part_node_ids(pn,nodeids);
2856 if(err == Z_ERR) {
2857 fprintf(stderr,"Error: getting nodeids\n");
2858 return(Z_ERR);
2861 #endif
2863 /* Echo "some" info
2864 *-----------------*/
2866 /* First node
2867 *-----------*/
2868 if(nn > 0) {
2869 i = 0;
2870 fprintf(stderr," Node %d of %d:\n",i+1,nn);
2872 #if (defined GT_USERD_API_200)
2874 if(Node_labels) {
2875 fprintf(stderr," id: %d\n",nodeids[i]);
2877 #endif
2878 if(num_dims == 3) {
2879 fprintf(stderr," x y z coordinates: %g %g %g\n",
2880 coords[0][i], coords[1][i], coords[2][i]);
2881 mm[0] = mm[1] = coords[0][i];
2882 mm[2] = mm[3] = coords[1][i];
2883 mm[4] = mm[5] = coords[2][i];
2885 else if(num_dims == 2) {
2886 fprintf(stderr," x y coordinates: %g %g\n",
2887 coords[0][i], coords[1][i]);
2888 mm[0] = mm[1] = coords[0][i];
2889 mm[2] = mm[3] = coords[1][i];
2891 else {
2892 fprintf(stderr," x coordinates: %g\n",
2893 coords[0][i]);
2894 mm[0] = mm[1] = coords[0][i];
2898 /* Last node
2899 *----------*/
2900 i = nn-1;
2901 if(i > 1) {
2902 fprintf(stderr," Node %d of %d:\n",i+1,nn);
2904 #if (defined GT_USERD_API_200)
2905 if(Node_labels) {
2906 fprintf(stderr," id: %d\n",nodeids[i]);
2908 #endif
2909 if(num_dims == 3) {
2910 fprintf(stderr," x y z coordinates: %g %g %g\n",
2911 coords[0][i], coords[1][i], coords[2][i]);
2913 else if(num_dims == 2) {
2914 fprintf(stderr," x y coordinates: %g %g\n",
2915 coords[0][i], coords[1][i]);
2917 else {
2918 fprintf(stderr," x coordinates: %g\n",
2919 coords[0][i]);
2924 /* Min and max coordinate values
2925 *------------------------------*/
2926 for(i=1; i<nn; ++i) {
2927 if(coords[0][i] < mm[0]) {
2928 mm[0] = coords[0][i];
2930 if(coords[0][i] > mm[1]) {
2931 mm[1] = coords[0][i];
2933 if(num_dims > 1) {
2934 if(coords[1][i] < mm[2]) {
2935 mm[2] = coords[1][i];
2937 if(coords[1][i] > mm[3]) {
2938 mm[3] = coords[1][i];
2941 if(num_dims > 2) {
2942 if(coords[2][i] < mm[4]) {
2943 mm[4] = coords[2][i];
2945 if(coords[2][i] > mm[5]) {
2946 mm[5] = coords[2][i];
2951 fprintf(stderr," Coordinate ranges:\n");
2952 fprintf(stderr," min x: %g\n",mm[0]);
2953 fprintf(stderr," max x: %g\n",mm[1]);
2954 if(num_dims > 1) {
2955 fprintf(stderr," min y: %g\n",mm[2]);
2956 fprintf(stderr," max y: %g\n",mm[3]);
2958 if(num_dims > 2) {
2959 fprintf(stderr," min z: %g\n",mm[4]);
2960 fprintf(stderr," max z: %g\n",mm[5]);
2963 /* Free the allocated memory - so far
2964 *-----------------------------------*/
2965 for(i=0; i<num_dims; ++i) {
2966 free(coords[i]);
2968 free(coords);
2970 #if (defined GT_USERD_API_200)
2971 if(Node_labels) {
2972 free(nodeids);
2974 #endif
2976 /* Get the block iblanking - if any
2977 *---------------------------------*/
2978 if(Pbuild[p].type == Z_IBLANKED) {
2980 iblanking = (int *) calloc(nn,sizeof(int));
2981 if(iblanking == (int *) NULL) {
2982 fprintf(stderr,"Error: allocating iblanking array\n");
2983 return(Z_ERR);
2986 err = USERD_get_block_iblanking(pn,iblanking);
2987 if(err == Z_ERR) {
2988 fprintf(stderr,"Error: getting block iblanking\n");
2989 return(Z_ERR);
2992 /* Echo "some" info
2993 *-----------------*/
2994 ib[Z_EXT] = 0;
2995 ib[Z_INT] = 0;
2996 ib[Z_BND] = 0;
2997 ib[Z_INTBND] = 0;
2998 ib[Z_SYM] = 0;
3000 for(i=0; i<nn; ++i) {
3001 ++ib[iblanking[i]];
3004 fprintf(stderr," Iblanking breakdown:\n");
3005 fprintf(stderr," Number of Z_EXT: %d\n",ib[Z_EXT]);
3006 fprintf(stderr," Number of Z_INT: %d\n",ib[Z_INT]);
3007 fprintf(stderr," Number of Z_BND: %d\n",ib[Z_BND]);
3008 fprintf(stderr," Number of Z_INTBND: %d\n",ib[Z_INTBND]);
3009 fprintf(stderr," Number of Z_SYM: %d\n",ib[Z_SYM]);
3011 free(iblanking);
3014 #if (defined GT_USERD_API_200)
3016 /* Get the ghost flags - if any
3017 *-----------------------------*/
3018 if(Pbuild[p].ghosts) {
3020 ghost_flag = (int *) calloc(ne,sizeof(int));
3021 if(ghost_flag == (int *) NULL) {
3022 fprintf(stderr,"Error: allocating ghost_flag array\n");
3023 return(Z_ERR);
3026 err = USERD_get_block_ghost_flags(pn,ghost_flag);
3027 if(err == Z_ERR) {
3028 fprintf(stderr,"Error: getting block ghost flags\n");
3029 return(Z_ERR);
3032 /* Echo "some" info
3033 *-----------------*/
3034 num_ghosts = 0;
3036 for(i=0; i<ne; ++i) {
3037 if(ghost_flag[i] > 0) {
3038 ++num_ghosts;
3042 fprintf(stderr," Block Ghost flag breakdown:\n");
3043 fprintf(stderr," %d ghost cells out of %d total cells\n",
3044 num_ghosts,ne);
3046 free(ghost_flag);
3049 /* Get the element ids - if any
3050 *-----------------------------*/
3051 if(Element_labels) {
3053 elemids = (int *) calloc(ne,sizeof(int));
3054 if(elemids == (int *) NULL) {
3055 fprintf(stderr,"Error: allocating elemids array\n");
3056 return(Z_ERR);
3060 et = cell_type;
3061 err = USERD_get_part_element_ids_by_type(pn,et,elemids);
3062 if(err == Z_ERR) {
3063 fprintf(stderr,"Error: getting element ids\n");
3064 return(Z_ERR);
3067 /* First element of the type
3068 *--------------------------*/
3069 i = 0;
3070 fprintf(stderr," %s Element %d of %d:\n",Elem_info[et].name,i+1,ne);
3071 fprintf(stderr," id: %d\n",elemids[i]);
3073 /* Last element of the type
3074 *-------------------------*/
3075 i = ne - 1;
3076 if(i > 0) {
3077 fprintf(stderr," %s Element %d of %d:\n",Elem_info[et].name,i+1,ne);
3078 fprintf(stderr," id: %d\n",elemids[i]);
3081 free(elemids);
3083 #endif
3085 else {
3086 fprintf(stderr," Empty structured part\n");
3090 /* Get border availability
3091 *------------------------*/
3092 err = USERD_get_border_availability(pn,num_elems);
3093 if(err == Z_OK) {
3095 /* Get border elements - if any
3096 *-----------------------------*/
3097 for(et=0; et<Z_MAXTYPE; ++et) {
3098 ne = num_elems[et];
3099 if(ne > 0) {
3101 conns = (int **) calloc(ne,sizeof(int *));
3102 if(conns == (int **) NULL) {
3103 fprintf(stderr,"Error: allocating border conns array\n");
3104 return(Z_ERR);
3106 else {
3107 for(i=0; i<ne; ++i) {
3108 conns[i] = (int *) calloc(Elem_info[et].con_len,sizeof(int));
3109 if(conns[i] == (int *) NULL) {
3110 fprintf(stderr,"Error: allocating border conns array\n");
3111 return(Z_ERR);
3116 parent_type = (short *) calloc(ne,sizeof(short));
3117 if(parent_type == (short *) NULL) {
3118 fprintf(stderr,"Error: allocating border parent_type array\n");
3119 return(Z_ERR);
3122 parent_num = (int *) calloc(ne,sizeof(int));
3123 if(parent_num == (int *) NULL) {
3124 fprintf(stderr,"Error: allocating border parent_num array\n");
3125 return(Z_ERR);
3129 err = USERD_get_border_elements_by_type(pn,
3131 conns,
3132 parent_type,
3133 parent_num);
3134 if(err == Z_ERR) {
3135 fprintf(stderr,"Error: getting border elements\n");
3136 return(Z_ERR);
3140 /* Echo "some" info
3141 *-----------------*/
3143 /* First element of the type
3144 *--------------------------*/
3145 i = 0;
3146 fprintf(stderr," %s border element %d of %d:\n",
3147 Elem_info[et].name,i+1,ne);
3148 fprintf(stderr," Parent type: %s\n",
3149 Elem_info[parent_type[i]].name);
3150 fprintf(stderr," Parent num: %d\n",parent_num[i]);
3151 fprintf(stderr," connectivity:");
3152 for(j=0; j<Elem_info[et].con_len; ++j) {
3153 fprintf(stderr," %d",conns[i][j]);
3155 fprintf(stderr,"\n");
3157 /* Last element of the type
3158 *-------------------------*/
3159 i = ne - 1;
3160 if(i > 0) {
3161 fprintf(stderr," %s border element %d of %d:\n",
3162 Elem_info[et].name,i+1,ne);
3163 fprintf(stderr," Parent type: %s\n",
3164 Elem_info[parent_type[i]].name);
3165 fprintf(stderr," Parent num: %d\n",parent_num[i]);
3166 fprintf(stderr," connectivity:");
3167 for(j=0; j<Elem_info[et].con_len; ++j) {
3168 fprintf(stderr," %d",conns[i][j]);
3170 fprintf(stderr,"\n");
3174 /* Free the allocated memory
3175 *--------------------------*/
3176 for(i=0; i<ne; ++i) {
3177 free(conns[i]);
3179 free(conns);
3180 free(parent_type);
3181 free(parent_num);
3185 } /* end for p = 0 to Num_parts */
3187 return(Z_OK);
3191 /*----------------
3192 * gold_var_loader
3193 *----------------*/
3194 static int
3195 gold_var_loader(int var_time_step)
3197 int i, j;
3198 int err;
3199 int v, vn;
3200 int var_timeset;
3201 int p, pn;
3202 int et, e1, e2;
3203 int num_comps;
3204 int num_dims;
3205 int nsize;
3206 int comp;
3207 int bdim[3];
3208 int ne;
3209 int cell_type;
3210 float constant_val;
3211 char line1[Z_BUFL];
3212 char line2[Z_BUFL];
3213 float *values;
3214 float minv,maxv;
3215 int bd1,bd2,bd3;
3218 fprintf(stderr,"\n--------------- var_loader --------------\n");
3220 for(v=0; v<Num_vars; ++v) {
3221 vn = v + 1;
3223 if(v > 0) {
3224 fprintf(stderr,"\n");
3226 if(Varinfo[v].classify == Z_PER_NODE) {
3227 fprintf(stderr," Z_PER_NODE Variable %d:\n",vn);
3229 else {
3230 fprintf(stderr," Z_PER_ELEM Variable %d:\n",vn);
3234 if(Num_time_sets > 0) {
3235 /* Get the timeset used for the variable
3236 *---------------------------------------*/
3237 var_timeset = Varinfo[v].timeset;
3239 /* Get the number of time steps for this timeset
3240 *----------------------------------------------*/
3241 Num_time_steps = USERD_get_num_of_time_steps(var_timeset);
3242 if(Num_time_steps < 1) {
3243 fprintf(stderr," Error: Number of time steps returned: %d\n",
3244 Num_time_steps);
3245 fprintf(stderr," (Must be >0 to be okay)\n");
3246 return(Z_ERR);
3248 if(var_time_step > (Num_time_steps - 1)) {
3249 var_time_step = Num_time_steps - 1;
3252 /* Set the timeset and step - to first step by default, but
3253 * can set it at others using -vts command argument
3254 *---------------------------------------------------------*/
3255 USERD_set_time_set_and_step(var_timeset,var_time_step);
3257 fprintf(stderr," Using timeset: %d (step range is %d through %d)\n",
3258 var_timeset,0,Num_time_steps-1);
3259 fprintf(stderr," Using time step: %d\n",var_time_step);
3263 /* Constants
3264 *----------*/
3265 if(Varinfo[v].type == Z_CONSTANT) {
3267 constant_val = USERD_get_constant_val(vn,FALSE);
3268 fprintf(stderr," Constant (%s):\n",Varinfo[v].description);
3269 fprintf(stderr," value: %g\n",constant_val);
3271 if(Varinfo[v].complex) {
3272 constant_val = USERD_get_constant_val(vn,TRUE);
3273 fprintf(stderr," value (imag): %g\n",constant_val);
3277 /* Scalars, Vectors, Tensors
3278 *--------------------------*/
3279 else {
3281 /* Get the var description line
3282 *-----------------------------*/
3283 err = USERD_get_descrip_lines(Z_VARI,vn,FALSE,line1,line2);
3284 if(err == Z_OK) {
3285 fprintf(stderr," Desc line: %s\n",line1);
3287 else {
3288 fprintf(stderr,"Error: getting var description line\n");
3289 return(Z_ERR);
3292 if(Varinfo[v].complex) {
3293 err = USERD_get_descrip_lines(Z_VARI,vn,TRUE,line1,line2);
3294 if(err == Z_OK) {
3295 fprintf(stderr," Desc line (imag): %s\n",line1);
3297 else {
3298 fprintf(stderr,"Error: getting var description line (imag)\n");
3299 return(Z_ERR);
3304 /* Get the values by component
3305 *-----------------------------*/
3306 if(Varinfo[v].type == Z_SCALAR) {
3307 num_comps = 1;
3309 else if(Varinfo[v].type == Z_VECTOR) {
3310 num_comps = 3;
3312 else if(Varinfo[v].type == Z_TENSOR) {
3313 num_comps = 6;
3315 else if(Varinfo[v].type == Z_TENSOR9) {
3316 num_comps = 9;
3320 /* Per_Node
3321 *---------*/
3322 if(Varinfo[v].classify == Z_PER_NODE) {
3324 for(p=0; p<Num_parts; ++p) {
3325 pn = p + 1;
3327 if(Pbuild[p].type == Z_UNSTRUCTURED) {
3328 nsize = Pbuild[p].nn;
3330 else {
3331 for(comp=0; comp<3; ++comp) {
3332 if(Pbuild[p].ne[comp] < 1) {
3333 bdim[comp] = 1;
3335 else {
3336 bdim[comp] = Pbuild[p].ne[comp];
3339 nsize = bdim[0] * bdim[1] * bdim[2];
3343 fprintf(stderr," For part %d, with %d nodes:\n",pn,nsize);
3345 if(nsize > 0) {
3346 values = (float *) calloc((nsize+1),sizeof(float));
3347 if(values == (float *) NULL) {
3348 fprintf(stderr,"Error: alocating variable values\n");
3349 return(Z_ERR);
3352 for(comp=0; comp<num_comps; ++comp) {
3354 err = USERD_get_var_by_component(vn,
3356 Varinfo[v].type,
3358 FALSE,
3359 comp,
3360 values);
3361 if(err == Z_UNDEF) {
3362 fprintf(stderr," Variable not defined on this part\n");
3366 /* For the component, show 1st node, last node, min, max values
3367 *-------------------------------------------------------------*/
3368 minv = maxv = values[1];
3369 for(i=2; i<=nsize; ++i) {
3370 if(values[i] < minv) {
3371 minv = values[i];
3373 if(values[i] > maxv) {
3374 maxv = values[i];
3378 fprintf(stderr," For component %d: \n",comp);
3379 fprintf(stderr," node %10d value: %g\n",1,values[1]);
3380 fprintf(stderr," node %10d value: %g\n",nsize,values[nsize]);
3381 fprintf(stderr," min value: %g\n",minv);
3382 fprintf(stderr," max value: %g\n",maxv);
3384 if(Varinfo[v].complex) {
3385 err = USERD_get_var_by_component(vn,
3387 Varinfo[v].type,
3389 FALSE,
3390 comp,
3391 values);
3392 if(err == Z_UNDEF) {
3393 fprintf(stderr," Variable not defined on this part\n");
3396 /* For the component, show 1st node, last node, min, max values
3397 *-------------------------------------------------------------*/
3398 minv = maxv = values[1];
3399 for(i=2; i<=nsize; ++i) {
3400 if(values[i] < minv) {
3401 minv = values[i];
3403 if(values[i] > maxv) {
3404 maxv = values[i];
3408 fprintf(stderr," For component %d (imag): \n",comp);
3409 fprintf(stderr," node %10d value: %g\n",1,values[1]);
3410 fprintf(stderr," node %10d value: %g\n",nsize,values[nsize]);
3411 fprintf(stderr," min value: %g\n",minv);
3412 fprintf(stderr," max value: %g\n",maxv);
3415 free(values);
3420 /* Per_Elem
3421 *---------*/
3422 else {
3423 for(p=0; p<Num_parts; ++p) {
3424 pn = p + 1;
3426 if(Pbuild[p].type != Z_UNSTRUCTURED) {
3428 for(comp=0; comp<3; ++comp) {
3429 if(Pbuild[p].ne[comp] < 1) {
3430 bdim[comp] = 1;
3432 else {
3433 bdim[comp] = Pbuild[p].ne[comp];
3437 bd1 = bdim[0]-1;
3438 if(bd1 < 1) {
3439 bd1 = 1;
3441 bd2 = bdim[1]-1;
3442 if(bd2 < 1) {
3443 bd2 = 1;
3445 bd3 = bdim[2]-1;
3446 if(bd3 < 1) {
3447 bd3 = 1;
3449 nsize = bd1 * bd2 * bd3;
3452 /* Determine cell type
3453 *--------------------*/
3454 num_dims = 3;
3455 for(i=0; i<3; ++i) {
3456 if(bdim[i] == 1) {
3457 --num_dims;
3460 if(num_dims == 3) {
3461 cell_type = Z_HEX08;
3463 else if(num_dims == 2) {
3464 cell_type = Z_QUA04;
3466 else {
3467 cell_type = Z_BAR02;
3471 if(Pbuild[p].type == Z_UNSTRUCTURED) {
3472 e1 = 0;
3473 e2 = Z_MAXTYPE-1;
3475 else {
3476 e1 = e2 = cell_type;
3479 for(et=e1; et<=e2; ++et) {
3481 if(Pbuild[p].type == Z_UNSTRUCTURED) {
3482 nsize = Pbuild[p].ne[et];
3485 if(nsize > 0) {
3487 fprintf(stderr," For part %d, with %d elems of type %s:\n",
3488 pn,nsize,Elem_info[et].name);
3491 values = (float *) calloc((nsize+1),sizeof(float));
3492 if(values == (float *) NULL) {
3493 fprintf(stderr,"Error: alocating variable values\n");
3494 return(Z_ERR);
3497 for(comp=0; comp<num_comps; ++comp) {
3499 err = USERD_get_var_by_component(vn,
3501 Varinfo[v].type,
3503 FALSE,
3504 comp,
3505 values);
3506 if(err == Z_UNDEF) {
3507 fprintf(stderr," Variable not defined on this part\n");
3510 /* For the component, show 1st elem, last elem, min, max values
3511 *-------------------------------------------------------------*/
3512 minv = maxv = values[1];
3513 for(i=2; i<=nsize; ++i) {
3514 if(values[i] < minv) {
3515 minv = values[i];
3517 if(values[i] > maxv) {
3518 maxv = values[i];
3522 fprintf(stderr," For component %d: \n",comp);
3523 fprintf(stderr," elem %10d value: %g\n",1,values[1]);
3524 fprintf(stderr," elem %10d value: %g\n",nsize,values[nsize]);
3525 fprintf(stderr," min value: %g\n",minv);
3526 fprintf(stderr," max value: %g\n",maxv);
3528 if(Varinfo[v].complex) {
3529 err = USERD_get_var_by_component(vn,
3531 Varinfo[v].type,
3533 FALSE,
3534 comp,
3535 values);
3536 if(err == Z_UNDEF) {
3537 fprintf(stderr," Variable not defined on this part\n");
3540 /* For the component, show 1st elem, last elem, min, max values
3541 *-------------------------------------------------------------*/
3542 minv = maxv = values[1];
3543 for(i=2; i<=nsize; ++i) {
3544 if(values[i] < minv) {
3545 minv = values[i];
3547 if(values[i] > maxv) {
3548 maxv = values[i];
3552 fprintf(stderr," For component %d (imag): \n",comp);
3553 fprintf(stderr," elem %10d value: %g\n",1,values[1]);
3554 fprintf(stderr," elem %10d value: %g\n",nsize,values[nsize]);
3555 fprintf(stderr," min value: %g\n",minv);
3556 fprintf(stderr," max value: %g\n",maxv);
3560 free(values);
3568 return(Z_OK);
3571 #else
3573 /*-------------
3574 * part_builder
3575 *-------------*/
3576 static int
3577 part_builder(int geom_time_step)
3579 int i, j;
3580 int err;
3581 int p, pn;
3582 int et, ne;
3583 int *elemids[Z_MAXTYPE];
3584 int **conns[Z_MAXTYPE];
3585 int nn;
3586 int comp;
3587 int bdim[3];
3588 int ib[5];
3589 int num_dims;
3590 int cell_type;
3591 float mm[6];
3592 float **coords;
3593 int *nodeids;
3594 int *iblanking;
3595 CRD *crds;
3596 int bd1,bd2,bd3;
3599 fprintf(stderr,"\n------------- part_builder --------------\n");
3602 if(Num_time_steps > 1) {
3603 if(geom_time_step > (Num_time_steps - 1)) {
3604 geom_time_step = Num_time_steps - 1;
3607 /* Set the time step - to first step by default, but
3608 * can set it at others using -gts command argument
3609 *---------------------------------------------------*/
3610 USERD_set_time_step(geom_time_step);
3612 fprintf(stderr," Using time step: %d (where range is %d through %d\n",
3613 geom_time_step,0,Num_time_steps-1);
3617 /* Get the global coords
3618 *----------------------*/
3619 nn = USERD_get_number_of_global_nodes();
3621 if(nn > 0) {
3623 crds = (CRD *) calloc(nn,sizeof(CRD));
3624 if(crds == (CRD *) NULL) {
3625 fprintf(stderr,"Error: allocating crds array\n");
3626 return(Z_ERR);
3629 if(Node_labels) {
3630 nodeids = (int *) calloc(nn,sizeof(int));
3631 if(nodeids == (int *) NULL) {
3632 fprintf(stderr,"Error: allocating nodeids array\n");
3633 return(Z_ERR);
3638 err = USERD_get_global_coords(crds);
3639 if(err == Z_ERR) {
3640 fprintf(stderr,"Error: getting unstructured coords\n");
3641 return(Z_ERR);
3644 if(Node_labels) {
3645 err = USERD_get_global_node_ids(nodeids);
3646 if(err == Z_ERR) {
3647 fprintf(stderr,"Error: getting nodeids\n");
3648 return(Z_ERR);
3652 /* Echo "some" info
3653 *-----------------*/
3655 /* First node
3656 *-----------*/
3657 i = 0;
3658 fprintf(stderr," Node %d of %d:\n",i+1,nn);
3659 if(Node_labels) {
3660 fprintf(stderr," id: %d\n",nodeids[i]);
3662 fprintf(stderr," x y z coordinates: %g %g %g\n",
3663 crds[i].xyz[0], crds[i].xyz[1], crds[i].xyz[2]);
3664 mm[0] = mm[1] = crds[i].xyz[0];
3665 mm[2] = mm[3] = crds[i].xyz[1];
3666 mm[4] = mm[5] = crds[i].xyz[2];
3669 /* Last node
3670 *----------*/
3671 i = nn-1;
3672 if(i > 0) {
3673 fprintf(stderr," Node %d of %d:\n",i+1,nn);
3674 if(Node_labels) {
3675 fprintf(stderr," id: %d\n",nodeids[i]);
3677 fprintf(stderr," x y z coordinates: %g %g %g\n",
3678 crds[i].xyz[0], crds[i].xyz[1], crds[i].xyz[2]);
3681 /* Min and max coordinate values
3682 *------------------------------*/
3683 for(i=1; i<nn; ++i) {
3684 if(crds[i].xyz[0] < mm[0]) {
3685 mm[0] = crds[i].xyz[0];
3687 if(crds[i].xyz[0] > mm[1]) {
3688 mm[1] = crds[i].xyz[0];
3690 if(crds[i].xyz[1] < mm[2]) {
3691 mm[2] = crds[i].xyz[1];
3693 if(crds[i].xyz[1] > mm[3]) {
3694 mm[3] = crds[i].xyz[1];
3696 if(crds[i].xyz[2] < mm[4]) {
3697 mm[4] = crds[i].xyz[2];
3699 if(crds[i].xyz[2] > mm[5]) {
3700 mm[5] = crds[i].xyz[2];
3704 fprintf(stderr," Global coordinate ranges:\n");
3705 fprintf(stderr," min x: %g\n",mm[0]);
3706 fprintf(stderr," max x: %g\n",mm[1]);
3707 fprintf(stderr," min y: %g\n",mm[2]);
3708 fprintf(stderr," max y: %g\n",mm[3]);
3709 fprintf(stderr," min z: %g\n",mm[4]);
3710 fprintf(stderr," max z: %g\n",mm[5]);
3713 /* Free the allocated memory
3714 *--------------------------*/
3715 free(crds);
3716 if(Node_labels) {
3717 free(nodeids);
3723 for(p=0; p<Num_parts; ++p) {
3724 pn = p+1;
3726 fprintf(stderr,"\n");
3727 fprintf(stderr," Part %d:\n",pn);
3729 /*-----------------------
3730 * For unstructured parts
3731 *-----------------------*/
3732 if(Pbuild[p].type == Z_UNSTRUCTURED) {
3734 for(et=0; et<Z_MAXTYPE; ++et) {
3735 ne = Pbuild[p].ne[et];
3737 if(ne > 0) {
3739 conns[et] = (int **) calloc(ne,sizeof(int *));
3740 if(conns[et] == (int **) NULL) {
3741 fprintf(stderr,"Error: allocating conns array\n");
3742 return(Z_ERR);
3744 else {
3745 for(i=0; i<ne; ++i) {
3746 conns[et][i] = (int *) calloc(Elem_info[et].con_len,sizeof(int));
3747 if(conns[et][i] == (int *) NULL) {
3748 fprintf(stderr,"Error: allocating conns array\n");
3749 return(Z_ERR);
3754 if(Element_labels) {
3755 elemids[et] = (int *) calloc(ne,sizeof(int));
3756 if(elemids[et] == (int *) NULL) {
3757 fprintf(stderr,"Error: allocating elemids array\n");
3758 return(Z_ERR);
3764 /* Get the elements
3765 *-----------------*/
3766 err = USERD_get_element_connectivities_for_part(pn,conns);
3767 if(err == Z_ERR) {
3768 fprintf(stderr,"Error: getting element connectivities\n");
3769 return(Z_ERR);
3772 /* Get the element ids - if any
3773 *-----------------------------*/
3774 if(Element_labels) {
3775 err = USERD_get_element_ids_for_part(pn,elemids);
3776 if(err == Z_ERR) {
3777 fprintf(stderr,"Error: getting element ids\n");
3778 return(Z_ERR);
3782 /* Echo "some" info
3783 *-----------------*/
3784 for(et=0; et<Z_MAXTYPE; ++et) {
3785 ne = Pbuild[p].ne[et];
3787 if(ne > 0) {
3789 /* First element of the type
3790 *--------------------------*/
3791 i = 0;
3792 fprintf(stderr," %s Element %d of %d:\n",Elem_info[et].name,i+1,ne);
3793 if(Element_labels) {
3794 fprintf(stderr," id: %d\n",elemids[et][i]);
3796 fprintf(stderr," connectivity:");
3797 for(j=0; j<Elem_info[et].con_len; ++j) {
3798 fprintf(stderr," %d",conns[et][i][j]);
3800 fprintf(stderr,"\n");
3802 /* Last element of the type
3803 *-------------------------*/
3804 i = ne - 1;
3805 if(i > 0) {
3806 fprintf(stderr," %s Element %d of %d:\n",Elem_info[et].name,i+1,ne);
3807 if(Element_labels) {
3808 fprintf(stderr," id: %d\n",elemids[et][i]);
3810 fprintf(stderr," connectivity:");
3811 for(j=0; j<Elem_info[et].con_len; ++j) {
3812 fprintf(stderr," %d",conns[et][i][j]);
3814 fprintf(stderr,"\n");
3819 /* Free the allocated memory
3820 *--------------------------*/
3821 for(et=0; et<Z_MAXTYPE; ++et) {
3822 ne = Pbuild[p].ne[et];
3824 if(ne > 0) {
3825 for(i=0; i<ne; ++i) {
3826 free(conns[et][i]);
3828 free(conns[et]);
3830 if(Element_labels) {
3831 free(elemids[et]);
3838 /*---------------------
3839 * For structured parts
3840 *---------------------*/
3841 else {
3843 /* Get the block coords
3844 *---------------------*/
3845 for(comp=0; comp<3; ++comp) {
3846 if(Pbuild[p].ne[comp] < 1) {
3847 bdim[comp] = 1;
3849 else {
3850 bdim[comp] = Pbuild[p].ne[comp];
3853 nn = bdim[0] * bdim[1] * bdim[2];
3855 bd1 = bdim[0]-1;
3856 if(bd1 < 1) {
3857 bd1 = 1;
3859 bd2 = bdim[1]-1;
3860 if(bd2 < 1) {
3861 bd2 = 1;
3863 bd3 = bdim[2]-1;
3864 if(bd3 < 1) {
3865 bd3 = 1;
3867 ne = bd1 * bd2 * bd3;
3870 /* Determine cell type
3871 *--------------------*/
3872 num_dims = 3;
3873 for(i=0; i<3; ++i) {
3874 if(bdim[i] == 1) {
3875 --num_dims;
3878 if(num_dims == 3) {
3879 cell_type = Z_HEX08;
3881 else if(num_dims == 2) {
3882 cell_type = Z_QUA04;
3884 else {
3885 cell_type = Z_BAR02;
3888 coords = (float **) calloc(num_dims,sizeof(float *));
3889 if(coords == (float **) NULL) {
3890 fprintf(stderr,"Error: allocating coords array\n");
3891 return(Z_ERR);
3893 else {
3894 for(i=0; i<num_dims; ++i) {
3895 coords[i] = (float *) calloc(nn,sizeof(float));
3896 if(coords[i] == (float *) NULL) {
3897 fprintf(stderr,"Error: allocating coords array\n");
3898 return(Z_ERR);
3903 /* Get the coords
3904 *---------------*/
3905 for(comp=0; comp<num_dims; ++comp) {
3906 err = USERD_get_block_coords_by_component(pn,comp,coords[comp]);
3907 if(err == Z_ERR) {
3908 fprintf(stderr,"Error: getting block coords\n");
3909 return(Z_ERR);
3914 /* Echo "some" info
3915 *-----------------*/
3917 /* First node
3918 *-----------*/
3919 if(nn > 0) {
3920 i = 0;
3921 fprintf(stderr," Node %d of %d:\n",i+1,nn);
3923 if(num_dims == 3) {
3924 fprintf(stderr," x y z coordinates: %g %g %g\n",
3925 coords[0][i], coords[1][i], coords[2][i]);
3926 mm[0] = mm[1] = coords[0][i];
3927 mm[2] = mm[3] = coords[1][i];
3928 mm[4] = mm[5] = coords[2][i];
3930 else if(num_dims == 2) {
3931 fprintf(stderr," x y coordinates: %g %g\n",
3932 coords[0][i], coords[1][i]);
3933 mm[0] = mm[1] = coords[0][i];
3934 mm[2] = mm[3] = coords[1][i];
3936 else {
3937 fprintf(stderr," x coordinates: %g\n",
3938 coords[0][i]);
3939 mm[0] = mm[1] = coords[0][i];
3943 /* Last node
3944 *----------*/
3945 i = nn-1;
3946 if(i > 1) {
3947 fprintf(stderr," Node %d of %d:\n",i+1,nn);
3949 if(num_dims == 3) {
3950 fprintf(stderr," x y z coordinates: %g %g %g\n",
3951 coords[0][i], coords[1][i], coords[2][i]);
3953 else if(num_dims == 2) {
3954 fprintf(stderr," x y coordinates: %g %g\n",
3955 coords[0][i], coords[1][i]);
3957 else {
3958 fprintf(stderr," x coordinates: %g\n",
3959 coords[0][i]);
3964 /* Min and max coordinate values
3965 *------------------------------*/
3966 for(i=2; i<=nn; ++i) {
3967 if(coords[0][i] < mm[0]) {
3968 mm[0] = coords[0][i];
3970 if(coords[0][i] > mm[1]) {
3971 mm[1] = coords[0][i];
3973 if(num_dims > 1) {
3974 if(coords[1][i] < mm[2]) {
3975 mm[2] = coords[1][i];
3977 if(coords[1][i] > mm[3]) {
3978 mm[3] = coords[1][i];
3981 if(num_dims > 2) {
3982 if(coords[2][i] < mm[4]) {
3983 mm[4] = coords[2][i];
3985 if(coords[2][i] > mm[5]) {
3986 mm[5] = coords[2][i];
3991 fprintf(stderr," Coordinate ranges:\n");
3992 fprintf(stderr," min x: %g\n",mm[0]);
3993 fprintf(stderr," max x: %g\n",mm[1]);
3994 if(num_dims > 1) {
3995 fprintf(stderr," min y: %g\n",mm[2]);
3996 fprintf(stderr," max y: %g\n",mm[3]);
3998 if(num_dims > 2) {
3999 fprintf(stderr," min z: %g\n",mm[4]);
4000 fprintf(stderr," max z: %g\n",mm[5]);
4003 /* Free the allocated memory - so far
4004 *-----------------------------------*/
4005 for(i=0; i<num_dims; ++i) {
4006 free(coords[i]);
4008 free(coords);
4011 /* Get the block iblanking - if any
4012 *---------------------------------*/
4013 if(Pbuild[p].type == Z_IBLANKED) {
4015 iblanking = (int *) calloc(nn,sizeof(int));
4016 if(iblanking == (int *) NULL) {
4017 fprintf(stderr,"Error: allocating iblanking array\n");
4018 return(Z_ERR);
4021 err = USERD_get_block_iblanking(pn,iblanking);
4022 if(err == Z_ERR) {
4023 fprintf(stderr,"Error: getting block iblanking\n");
4024 return(Z_ERR);
4027 /* Echo "some" info
4028 *-----------------*/
4029 ib[Z_EXT] = 0;
4030 ib[Z_INT] = 0;
4031 ib[Z_BND] = 0;
4032 ib[Z_INTBND] = 0;
4033 ib[Z_SYM] = 0;
4035 for(i=0; i<nn; ++i) {
4036 ++ib[iblanking[i]];
4039 fprintf(stderr," Iblanking breakdown:\n");
4040 fprintf(stderr," Number of Z_EXT: %d\n",ib[Z_EXT]);
4041 fprintf(stderr," Number of Z_INT: %d\n",ib[Z_INT]);
4042 fprintf(stderr," Number of Z_BND: %d\n",ib[Z_BND]);
4043 fprintf(stderr," Number of Z_INTBND: %d\n",ib[Z_INTBND]);
4044 fprintf(stderr," Number of Z_SYM: %d\n",ib[Z_SYM]);
4046 free(iblanking);
4051 return(Z_OK);
4055 /*-----------
4056 * var_loader
4057 *-----------*/
4058 static int
4059 var_loader(int var_time_step)
4061 int i, j, k;
4062 int err;
4063 int v, vn;
4064 int var_timeset;
4065 int p, pn;
4066 int et, e1, e2;
4067 int num_comps;
4068 int num_dims;
4069 int nsize;
4070 int comp;
4071 int bdim[3];
4072 int ne;
4073 int cell_type;
4074 float constant_val;
4075 char line1[Z_BUFL];
4076 char line2[Z_BUFL];
4077 float *values;
4078 float *tvalues;
4079 float minv[3],maxv[3];
4080 int bd1,bd2,bd3;
4083 fprintf(stderr,"\n--------------- var_loader --------------\n");
4085 if(Num_time_steps > 1 && v == 0) {
4086 if(var_time_step > (Num_time_steps - 1)) {
4087 var_time_step = Num_time_steps - 1;
4090 /* Set the time step - to first step by default, but
4091 * can set it at others using -vts command argument
4092 *---------------------------------------------------------*/
4093 USERD_set_time_step(var_time_step);
4095 fprintf(stderr," Using time step: %d (where range is %d through %d)\n\n",
4096 var_time_step,0,Num_time_steps-1);
4099 for(v=0; v<Num_vars; ++v) {
4100 vn = v + 1;
4102 if(v > 0) {
4103 fprintf(stderr,"\n");
4105 if(Varinfo[v].classify == Z_PER_NODE) {
4106 fprintf(stderr," Z_PER_NODE Variable %d:\n",vn);
4108 else {
4109 fprintf(stderr," Z_PER_ELEM Variable %d:\n",vn);
4112 /* Constants
4113 *----------*/
4114 if(Varinfo[v].type == Z_CONSTANT) {
4116 constant_val = USERD_get_constant_value(vn);
4117 fprintf(stderr," Constant (%s):\n",Varinfo[v].description);
4118 fprintf(stderr," value: %g\n",constant_val);
4122 /* Scalars, Vectors, Tensors
4123 *--------------------------*/
4124 else {
4126 /* Get the var description line
4127 *-----------------------------*/
4128 err = USERD_get_description_lines(Z_VARI,vn,line1,line2);
4129 if(err == Z_OK) {
4130 fprintf(stderr," Desc line: %s\n",line1);
4132 else {
4133 fprintf(stderr,"Error: getting var description line\n");
4134 return(Z_ERR);
4138 /* Get the values by component
4139 *-----------------------------*/
4140 if(Varinfo[v].type == Z_SCALAR) {
4141 num_comps = 1;
4143 else if(Varinfo[v].type == Z_VECTOR) {
4144 num_comps = 3;
4146 else if(Varinfo[v].type == Z_TENSOR) {
4147 num_comps = 6;
4149 else if(Varinfo[v].type == Z_TENSOR9) {
4150 num_comps = 9;
4154 /* Per_Node
4155 *---------*/
4156 if(Varinfo[v].classify == Z_PER_NODE) {
4158 for(p=0; p<Num_parts; ++p) {
4159 pn = p + 1;
4161 if(Pbuild[p].type == Z_UNSTRUCTURED) {
4162 nsize = Pbuild[p].nn;
4164 else {
4165 for(comp=0; comp<3; ++comp) {
4166 if(Pbuild[p].ne[comp] < 1) {
4167 bdim[comp] = 1;
4169 else {
4170 bdim[comp] = Pbuild[p].ne[comp];
4173 nsize = bdim[0] * bdim[1] * bdim[2];
4177 fprintf(stderr," For part %d, with %d nodes:\n",pn,nsize);
4179 if(nsize > 0) {
4180 values = (float *) calloc((num_comps * nsize),sizeof(float));
4181 if(values == (float *) NULL) {
4182 fprintf(stderr,"Error: alocating variable values\n");
4183 return(Z_ERR);
4186 if(num_comps == 1) {
4188 if(Pbuild[p].type == Z_UNSTRUCTURED) {
4189 err = USERD_get_scalar_values(vn,
4192 values);
4193 if(err == Z_ERR) {
4194 fprintf(stderr,"Error: getting scalar values\n");
4195 return(Z_ERR);
4198 else {
4199 err = USERD_get_block_scalar_values(pn,
4201 values);
4202 if(err == Z_ERR) {
4203 fprintf(stderr,"Error: getting block scalar values\n");
4204 return(Z_ERR);
4208 /* For the component, show 1st node, last node, min, max values
4209 *-------------------------------------------------------------*/
4210 minv[0] = maxv[0] = values[0];
4211 for(i=0; i<nsize; ++i) {
4212 if(values[i] < minv[0]) {
4213 minv[0] = values[i];
4215 if(values[i] > maxv[0]) {
4216 maxv[0] = values[i];
4220 fprintf(stderr," node %10d value: %g\n",1,values[0]);
4221 fprintf(stderr," node %10d value: %g\n",nsize,values[nsize-1]);
4222 fprintf(stderr," min value: %g\n",minv[0]);
4223 fprintf(stderr," max value: %g\n",maxv[0]);
4227 else if(num_comps == 3) {
4229 if(Pbuild[p].type == Z_UNSTRUCTURED) {
4230 err = USERD_get_vector_values(vn,
4233 values);
4234 if(err == Z_ERR) {
4235 fprintf(stderr,"Error: getting vector values\n");
4236 return(Z_ERR);
4239 else {
4241 tvalues = (float *) calloc(nsize,sizeof(float));
4242 if(tvalues == (float *) NULL) {
4243 fprintf(stderr,"Error: alocating tvalues array\n");
4244 return(Z_ERR);
4247 for(i=0; i<3; ++i) {
4248 err = USERD_get_block_vector_values_by_component(pn,
4251 tvalues);
4252 if(err == Z_ERR) {
4253 fprintf(stderr,"Error: getting vector values\n");
4254 return(Z_ERR);
4256 for(j=0; j<nsize; ++j) {
4257 k = j*3 + i;
4258 values[k] = tvalues[j];
4261 free(tvalues);
4264 /* For the component, show 1st node, last node, min, max values
4265 *-------------------------------------------------------------*/
4266 minv[0] = maxv[0] = values[0];
4267 minv[1] = maxv[1] = values[1];
4268 minv[2] = maxv[2] = values[2];
4269 for(i=0; i<nsize; ++i) {
4270 j = i*3;
4271 for(k=0; k<3; ++k) {
4272 if(values[j+k] < minv[k]) {
4273 minv[k] = values[j+k];
4275 if(values[j+k] > maxv[k]) {
4276 maxv[k] = values[j+k];
4281 fprintf(stderr," node %10d values: %g %g %g\n",1,
4282 values[0],values[1],values[2]);
4283 fprintf(stderr," node %10d values: %g %g %g\n",nsize,
4284 values[3*nsize-3],values[3*nsize-2],values[3*nsize-1]);
4285 fprintf(stderr," min values: %g %g %g\n",
4286 minv[0],minv[1],minv[2]);
4287 fprintf(stderr," max values: %g %g %g\n",
4288 maxv[0],maxv[1],maxv[2]);
4291 free(values);
4296 /* Per_Elem
4297 *---------*/
4298 else {
4299 for(p=0; p<Num_parts; ++p) {
4300 pn = p + 1;
4302 if(Pbuild[p].type != Z_UNSTRUCTURED) {
4304 for(comp=0; comp<3; ++comp) {
4305 if(Pbuild[p].ne[comp] < 1) {
4306 bdim[comp] = 1;
4308 else {
4309 bdim[comp] = Pbuild[p].ne[comp];
4312 bd1 = bdim[0]-1;
4313 if(bd1 < 1) {
4314 bd1 = 1;
4316 bd2 = bdim[1]-1;
4317 if(bd2 < 1) {
4318 bd2 = 1;
4320 bd3 = bdim[2]-1;
4321 if(bd3 < 1) {
4322 bd3 = 1;
4324 nsize = bd1 * bd2 * bd3;
4327 /* Determine cell type
4328 *--------------------*/
4329 num_dims = 3;
4330 for(i=0; i<3; ++i) {
4331 if(bdim[i] == 1) {
4332 --num_dims;
4335 if(num_dims == 3) {
4336 cell_type = Z_HEX08;
4338 else if(num_dims == 2) {
4339 cell_type = Z_QUA04;
4341 else {
4342 cell_type = Z_BAR02;
4346 if(Pbuild[p].type == Z_UNSTRUCTURED) {
4347 e1 = 0;
4348 e2 = Z_MAXTYPE-1;
4350 else {
4351 e1 = e2 = cell_type;
4354 for(et=e1; et<=e2; ++et) {
4356 if(Pbuild[p].type == Z_UNSTRUCTURED) {
4357 nsize = Pbuild[p].ne[et];
4360 if(nsize > 0) {
4362 fprintf(stderr," For part %d, with %d elems of type %s:\n",
4363 pn,nsize,Elem_info[et].name);
4365 values = (float *) calloc((num_comps * nsize),sizeof(float));
4366 if(values == (float *) NULL) {
4367 fprintf(stderr,"Error: alocating variable values\n");
4368 return(Z_ERR);
4371 if(num_comps == 1) {
4372 if(Pbuild[p].type == Z_UNSTRUCTURED) {
4373 err = USERD_get_scalar_values(vn,
4376 values);
4377 if(err == Z_ERR) {
4378 fprintf(stderr,"Error: getting scalar values\n");
4379 return(Z_ERR);
4382 else {
4383 err = USERD_get_block_scalar_values(pn,
4385 values);
4386 if(err == Z_ERR) {
4387 fprintf(stderr,"Error: getting block scalar values\n");
4388 return(Z_ERR);
4392 /* For the component, show 1st node, last node, min, max values
4393 *-------------------------------------------------------------*/
4394 minv[0] = maxv[0] = values[0];
4395 for(i=1; i<nsize; ++i) {
4396 if(values[i] < minv[0]) {
4397 minv[0] = values[i];
4399 if(values[i] > maxv[0]) {
4400 maxv[0] = values[i];
4404 fprintf(stderr," elem %10d value: %g\n",1,values[0]);
4405 fprintf(stderr," elem %10d value: %g\n",nsize,values[nsize-1]);
4406 fprintf(stderr," min value: %g\n",minv[0]);
4407 fprintf(stderr," max value: %g\n",maxv[0]);
4411 else if(num_comps == 3) {
4413 if(Pbuild[p].type == Z_UNSTRUCTURED) {
4414 err = USERD_get_vector_values(vn,
4417 values);
4418 if(err == Z_ERR) {
4419 fprintf(stderr,"Error: getting vector values\n");
4420 return(Z_ERR);
4423 else {
4425 tvalues = (float *) calloc(nsize,sizeof(float));
4426 if(tvalues == (float *) NULL) {
4427 fprintf(stderr,"Error: alocating tvalues array\n");
4428 return(Z_ERR);
4431 for(i=0; i<3; ++i) {
4432 err = USERD_get_block_vector_values_by_component(pn,
4435 tvalues);
4436 if(err == Z_ERR) {
4437 fprintf(stderr,"Error: getting vector values\n");
4438 return(Z_ERR);
4440 for(j=0; j<nsize; ++j) {
4441 k = j*3 + i;
4442 values[k] = tvalues[j];
4445 free(tvalues);
4448 /* For the component, show 1st node, last node, min, max values
4449 *-------------------------------------------------------------*/
4450 minv[0] = maxv[0] = values[0];
4451 minv[1] = maxv[1] = values[1];
4452 minv[2] = maxv[2] = values[2];
4453 for(i=1; i<=nsize; ++i) {
4454 j = i*3;
4455 for(k=0; k<3; ++k) {
4456 if(values[j+k] < minv[k]) {
4457 minv[k] = values[j+k];
4459 if(values[j+k] > maxv[k]) {
4460 maxv[k] = values[j+k];
4465 fprintf(stderr," elem %10d values: %g %g %g\n",1,
4466 values[0],values[1],values[2]);
4467 fprintf(stderr," elem %10d values: %g %g %g\n",nsize,
4468 values[3*nsize-3],values[3*nsize-2],values[3*nsize-1]);
4469 fprintf(stderr," min values: %g %g %g\n",
4470 minv[0],minv[1],minv[2]);
4471 fprintf(stderr," max values: %g %g %g\n",
4472 maxv[0],maxv[1],maxv[2]);
4475 free(values);
4483 return(Z_OK);
4486 #endif
4489 #if (defined GT_USERD_API_202)
4492 /*---------------
4493 * materials_info
4494 *---------------*/
4495 static int
4496 materials_info( void )
4498 int i,j;
4499 int err;
4500 int *num_materials;
4501 int *msids;
4502 char **msname;
4503 int *mids;
4504 char **mdesc;
4507 fprintf(stderr,"\n------------ materials_info --------------\n");
4509 /* Get the number of variables
4510 *----------------------------*/
4511 Num_materials_sets = USERD_get_number_of_material_sets();
4512 if(Num_materials_sets < 0) {
4513 fprintf(stderr,"Error: getting the number of material sets\n");
4514 return(Z_ERR);
4516 else {
4517 if(Num_materials_sets == 0) {
4518 fprintf(stderr," No materials sets in the model\n");
4519 return (Z_OK);
4521 else if(Num_materials_sets > 1) {
4522 fprintf(stderr," Number of materials sets: %d\n",Num_materials_sets);
4523 fprintf(stderr," Currently, EnSight 7.6 only supports 1 material set\n");
4524 return(Z_ERR);
4526 else {
4527 fprintf(stderr," Number of materials sets: %d\n",Num_materials_sets);
4531 /* Get the material set index list and names
4532 *------------------------------------------*/
4533 msids = (int *) calloc(Num_materials_sets,sizeof(int));
4534 if(msids == (int *)NULL) {
4535 fprintf(stderr," Problems allocating for material set ids\n");
4536 return(Z_ERR);
4539 num_materials = (int *) calloc(Num_materials_sets,sizeof(int));
4540 if(num_materials == (int *)NULL) {
4541 fprintf(stderr," Problems allocating for material set num materials\n");
4542 return(Z_ERR);
4545 msname = (char **) calloc(Num_materials_sets,sizeof(char *));
4546 if(msname == (char **)NULL) {
4547 fprintf(stderr," Problems allocating for material set names\n");
4548 return(Z_ERR);
4550 else {
4551 for(i=0; i<Num_materials_sets; ++i) {
4552 msname[i] = (char *) calloc(Z_BUFL,sizeof(char));
4553 if(msname[i] == (char *)NULL) {
4554 fprintf(stderr," Problems allocating for material set names\n");
4555 return(Z_ERR);
4560 err = USERD_get_matf_set_info(msids,msname);
4561 if(err == Z_ERR) {
4562 fprintf(stderr,"Error: getting material set info\n");
4564 else {
4565 for(i=0; i<Num_materials_sets; ++i) {
4567 /* Echo some feedback
4568 *-------------------*/
4569 fprintf(stderr," For Material set %d:\n",i+1);
4571 fprintf(stderr," id: %d\n",msids[i]);
4572 fprintf(stderr," name: %s\n",msname[i]);
4574 num_materials[i] = USERD_get_number_of_materials(i);
4575 if(num_materials[i] < 0) {
4576 fprintf(stderr,"Error: getting the number of materials in set %d\n",i);
4577 return (Z_ERR);
4579 else if(num_materials[i] == 0) {
4580 fprintf(stderr," No materials in Materials set %d\n",i);
4581 return (Z_OK);
4583 else {
4584 mids = (int *) calloc(num_materials[i],sizeof(int));
4585 if(mids == (int *)NULL) {
4586 fprintf(stderr," Problems allocating for material ids\n");
4587 return(Z_ERR);
4590 mdesc = (char **) calloc(num_materials[i],sizeof(char *));
4591 if(mdesc == (char **)NULL) {
4592 fprintf(stderr," Problems allocating for material desc\n");
4593 return(Z_ERR);
4595 else {
4596 for(j=0; j<num_materials[i]; ++j) {
4597 mdesc[j] = (char *) calloc(Z_BUFL,sizeof(char));
4598 if(mdesc[j] == (char *)NULL) {
4599 fprintf(stderr," Problems allocating for material desc\n");
4600 return(Z_ERR);
4605 err = USERD_get_matf_var_info(i,mids,mdesc);
4606 if(err == Z_ERR) {
4607 fprintf(stderr,"Error: getting material info\n");
4609 else {
4611 for(j=0; j<num_materials[i]; ++j) {
4612 /* Echo some feedback
4613 *-------------------*/
4614 fprintf(stderr," For Material %d:\n",j+1);
4616 fprintf(stderr," index: %d\n",mids[j]);
4617 fprintf(stderr," description: %s\n",mdesc[j]);
4624 /* Free the allocated memory
4625 *--------------------------*/
4626 for(i=0; i<Num_materials_sets; ++i) {
4627 free(msname[i]);
4629 for(j=0; j<num_materials[i]; ++j) {
4630 free(mdesc[j]);
4633 free(msname);
4634 free(msids);
4635 free(num_materials);
4636 free(mdesc);
4637 free(mids);
4639 return(Z_OK);
4643 /*----------------------
4644 * gold_materials_loader
4645 *----------------------*/
4646 static int
4647 gold_materials_loader(int geom_time_step)
4649 int i, j, k, ms, nn;
4650 int err, err1, err2;
4651 int geom_timeset;
4652 int p, pn;
4653 int et, e1, e2;
4654 int num_dims;
4655 int comp;
4656 int bdim[3];
4657 int ne;
4658 int cell_type;
4659 int bd1,bd2,bd3;
4660 int *ivals;
4661 float *fvals;
4662 int do_num;
4663 int mixed_present;
4664 int matf_size, matfv_size;
4667 fprintf(stderr,"\n-------------- materials_loader --------------\n");
4669 if(Num_time_sets > 0) {
4670 /* Get the timeset used for the geometry
4671 *--------------------------------------*/
4672 geom_timeset = USERD_get_geom_timeset_number();
4674 /* Get the number of time steps for this timeset
4675 *----------------------------------------------*/
4676 Num_time_steps = USERD_get_num_of_time_steps(geom_timeset);
4677 if(Num_time_steps < 1) {
4678 fprintf(stderr," Error: Num time steps returned: %d\n",Num_time_steps);
4679 fprintf(stderr," (Must be >0 to be okay)\n");
4680 return(Z_ERR);
4682 if(geom_time_step > (Num_time_steps - 1)) {
4683 geom_time_step = Num_time_steps - 1;
4686 /* Set the timeset and step - to first step by default, but
4687 * can set it at others using -gts command argument
4688 *---------------------------------------------------------*/
4689 USERD_set_time_set_and_step(geom_timeset,geom_time_step);
4691 fprintf(stderr," Using timeset: %d (step range is %d through %d)\n",
4692 geom_timeset,0,Num_time_steps-1);
4693 fprintf(stderr," Using time step: %d\n",geom_time_step);
4696 for(ms=0; ms<Num_materials_sets; ++ms) {
4697 fprintf(stderr,"\n");
4698 fprintf(stderr," Materials Set %d:\n",ms+1);
4700 for(p=0; p<Num_parts; ++p) {
4701 pn = p+1;
4703 fprintf(stderr,"\n");
4704 fprintf(stderr," Part %d:\n",pn);
4706 /*-----------------------
4707 * For unstructured parts
4708 *-----------------------*/
4709 if(Pbuild[p].type == Z_UNSTRUCTURED) {
4711 e1 = 0;
4712 e2 = Z_MAXTYPE;
4714 else {
4715 for(comp=0; comp<3; ++comp) {
4716 if(Pbuild[p].ne[comp] < 1) {
4717 bdim[comp] = 1;
4719 else {
4720 bdim[comp] = Pbuild[p].ne[comp];
4723 nn = bdim[0] * bdim[1] * bdim[2];
4725 bd1 = bdim[0]-1;
4726 if(bd1 < 1) {
4727 bd1 = 1;
4729 bd2 = bdim[1]-1;
4730 if(bd2 < 1) {
4731 bd2 = 1;
4733 bd3 = bdim[2]-1;
4734 if(bd3 < 1) {
4735 bd3 = 1;
4737 ne = bd1 * bd2 * bd3;
4739 /* Determine cell type
4740 *--------------------*/
4741 num_dims = 3;
4742 for(i=0; i<3; ++i) {
4743 if(bdim[i] == 1) {
4744 --num_dims;
4747 if(num_dims == 3) {
4748 cell_type = Z_HEX08;
4750 else if(num_dims == 2) {
4751 cell_type = Z_QUA04;
4753 else {
4754 cell_type = Z_BAR02;
4757 e1 = cell_type;
4758 e2 = cell_type + 1;
4762 for(et=e1; et<e2; ++et) {
4764 if(Pbuild[p].type == Z_UNSTRUCTURED) {
4765 ne = Pbuild[p].ne[et];
4768 if(ne > 0) {
4770 /* Get the material ids, if any
4771 *-----------------------------*/
4772 err = USERD_size_matf_data(ms,
4775 Z_MAT_INDEX,
4776 &matf_size);
4777 if(err == Z_OK && matf_size > 0) {
4780 /* Go get the material ids
4781 *------------------------*/
4782 ivals = (int *) calloc(matf_size,sizeof(int));
4783 if(ivals == (int *)NULL) {
4784 fprintf(stderr," Problems allocating for material ids\n");
4785 return(Z_ERR);
4787 err = USERD_load_matf_data(ms,
4790 Z_MAT_INDEX,
4791 ivals,
4792 fvals);
4793 if(err == Z_OK) {
4794 if(matf_size < 20) {
4795 fprintf(stderr," Printing all mat ids for %s elements\n",
4796 Elem_info[et].name);
4797 do_num = matf_size;
4799 else {
4800 fprintf(stderr," Printing first 20 mat ids for %s elements\n",
4801 Elem_info[et].name);
4802 do_num = 20;
4805 /* See if any mixed materials
4806 *---------------------------*/
4807 mixed_present = FALSE;
4808 for(k=0; k<matf_size; ++k) {
4809 if(ivals[k] < 0) {
4810 mixed_present = TRUE;
4811 break;
4815 /* Feedback
4816 *---------*/
4817 for(k=0; k<do_num; ++k) {
4818 fprintf(stderr," mat id[%d] = %d\n",k,ivals[k]);
4820 free(ivals);
4822 else {
4823 fprintf(stderr," Trouble getting mat ids for %s elements\n",
4824 Elem_info[et].name);
4825 free(ivals);
4826 return(Z_ERR);
4829 else {
4830 fprintf(stderr," %s elements have no material ids\n",
4831 Elem_info[et].name);
4835 /* Get the mixed material ids, if any
4836 *-----------------------------------*/
4837 if(mixed_present) {
4838 err1 = USERD_size_matf_data(ms,
4841 Z_MIX_INDEX,
4842 &matf_size);
4843 err2 = USERD_size_matf_data(ms,
4846 Z_MIX_VALUE,
4847 &matfv_size);
4849 if(err1 == Z_OK &&
4850 err2 == Z_OK &&
4851 matf_size > 0 &&
4852 matfv_size > 0) {
4854 /* Go get the material ids
4855 *------------------------*/
4856 ivals = (int *) calloc(matf_size,sizeof(int));
4857 if(ivals == (int *)NULL) {
4858 fprintf(stderr," Problems allocating for mixed material ids\n");
4859 return(Z_ERR);
4861 fvals = (float *) calloc(matfv_size,sizeof(float));
4862 if(fvals == (float *)NULL) {
4863 fprintf(stderr," Problems allocating for mixed material values\n");
4864 return(Z_ERR);
4867 err1 = USERD_load_matf_data(ms,
4870 Z_MIX_INDEX,
4871 ivals,
4872 fvals);
4874 err2 = USERD_load_matf_data(ms,
4877 Z_MIX_VALUE,
4878 ivals,
4879 fvals);
4880 if(err1 == Z_OK &&
4881 err2 == Z_OK) {
4882 if(matf_size < 20) {
4883 fprintf(stderr," Printing all mixed mat ids for %s elements\n",
4884 Elem_info[et].name);
4885 do_num = matf_size;
4887 else {
4888 fprintf(stderr," Printing first 20 mixed mat ids for %s elements\n",
4889 Elem_info[et].name);
4890 do_num = 20;
4892 for(k=0; k<do_num; ++k) {
4893 fprintf(stderr," mixed mat id[%d] = %d\n",k,ivals[k]);
4895 free(ivals);
4897 if(matfv_size < 20) {
4898 fprintf(stderr," Printing all mixed mat values for %s elements\n",
4899 Elem_info[et].name);
4900 do_num = matfv_size;
4902 else {
4903 fprintf(stderr," Printing first 20 mixed mat values for %s elements\n",
4904 Elem_info[et].name);
4905 do_num = 20;
4907 for(k=0; k<do_num; ++k) {
4908 fprintf(stderr," mixed mat val[%d] = %f\n",k,fvals[k]);
4910 free(fvals);
4912 else {
4913 fprintf(stderr," Trouble getting mixed mat ids or vals for %s elements\n",
4914 Elem_info[et].name);
4915 free(ivals);
4916 free(fvals);
4917 return(Z_ERR);
4920 else {
4921 fprintf(stderr," Trouble getting mixed mat sizes for %s elements\n",
4922 Elem_info[et].name);
4923 return(Z_ERR);
4926 else {
4927 fprintf(stderr," (%s elements have no mixed material ids)\n",
4928 Elem_info[et].name);
4934 return(Z_OK);
4937 #endif
4939 /*--------------
4940 * entity_querys
4941 *--------------*/
4942 static int
4943 entity_querys(int var_time_step)
4945 int i, j;
4946 int err;
4947 int v, vn;
4948 int var_timeset;
4949 int p, pn;
4950 int et, e1, e2;
4951 int num_comps;
4952 int num_dims;
4953 int nsize;
4954 int comp;
4955 int bdim[3];
4956 int ne;
4957 int cell_type;
4958 char line1[Z_BUFL];
4959 char line2[Z_BUFL];
4960 float qvals[3];
4961 int bd1,bd2,bd3;
4964 fprintf(stderr,"\n-------------- entity_querys ------------\n");
4965 fprintf(stderr," (scalar & vector variables only) \n");
4966 fprintf(stderr,"\n");
4968 #if (defined USERD_API_100)
4970 if(Num_time_steps > 1) {
4971 /* Get the number of time steps for this timeset
4972 *----------------------------------------------*/
4973 if(var_time_step > (Num_time_steps - 1)) {
4974 var_time_step = Num_time_steps - 1;
4977 /* Set the time step - to first step by default, but
4978 * can set it at others using -vts command argument
4979 *---------------------------------------------------------*/
4980 USERD_set_time_step(var_time_step);
4982 fprintf(stderr," Using time step: %d (where range is %d through %d)\n\n",
4983 var_time_step,0,Num_time_steps-1);
4985 #endif
4987 for(v=0; v<Num_vars; ++v) {
4988 vn = v + 1;
4990 /* Scalar or vectors only
4991 *-----------------------*/
4992 if(Varinfo[v].type == Z_SCALAR || Varinfo[v].type == Z_VECTOR) {
4995 if(Varinfo[v].classify == Z_PER_NODE) {
4996 fprintf(stderr," Z_PER_NODE Variable %d:\n",vn);
4998 else {
4999 fprintf(stderr," Z_PER_ELEM Variable %d:\n",vn);
5002 #if (defined GT_USERD_API_100)
5004 if(Num_time_sets > 0) {
5005 /* Get the timeset used for the variable
5006 *---------------------------------------*/
5007 var_timeset = Varinfo[v].timeset;
5009 /* Get the number of time steps for this timeset
5010 *----------------------------------------------*/
5011 Num_time_steps = USERD_get_num_of_time_steps(var_timeset);
5012 if(Num_time_steps < 1) {
5013 fprintf(stderr," Error: Number of time steps returned: %d\n",
5014 Num_time_steps);
5015 fprintf(stderr," (Must be >0 to be okay)\n");
5016 return(Z_ERR);
5018 if(var_time_step > (Num_time_steps - 1)) {
5019 var_time_step = Num_time_steps - 1;
5022 /* Set the timeset and step - to first step by default, but
5023 * can set it at others using -vts command argument
5024 *---------------------------------------------------------*/
5025 USERD_set_time_set_and_step(var_timeset,var_time_step);
5027 fprintf(stderr," Using timeset: %d (step range is %d through %d)\n",
5028 var_timeset,0,Num_time_steps-1);
5029 fprintf(stderr," Using time step: %d\n",var_time_step);
5031 #endif
5034 /* Get the var description line
5035 *-----------------------------*/
5036 #if (defined GT_USERD_API_100)
5037 err = USERD_get_descrip_lines(Z_VARI,vn,FALSE,line1,line2);
5038 if(err == Z_OK) {
5039 fprintf(stderr," Desc line: %s\n",line1);
5041 else {
5042 fprintf(stderr,"Error: getting var description line\n");
5043 return(Z_ERR);
5046 if(Varinfo[v].complex) {
5047 err = USERD_get_descrip_lines(Z_VARI,vn,TRUE,line1,line2);
5048 if(err == Z_OK) {
5049 fprintf(stderr," Desc line (imag): %s\n",line1);
5051 else {
5052 fprintf(stderr,"Error: getting var description line (imag)\n");
5053 return(Z_ERR);
5056 #else
5058 err = USERD_get_description_lines(Z_VARI,vn,line1,line2);
5059 if(err == Z_OK) {
5060 fprintf(stderr," Desc line: %s\n",line1);
5062 else {
5063 fprintf(stderr,"Error: getting var description line\n");
5064 return(Z_ERR);
5067 #endif
5069 /* Get the values by component
5070 *-----------------------------*/
5071 if(Varinfo[v].type == Z_SCALAR) {
5072 num_comps = 1;
5074 else if(Varinfo[v].type == Z_VECTOR) {
5075 num_comps = 3;
5078 /* Per_Node
5079 *---------*/
5080 if(Varinfo[v].classify == Z_PER_NODE) {
5082 for(p=0; p<Num_parts; ++p) {
5083 pn = p + 1;
5085 if(Pbuild[p].type == Z_UNSTRUCTURED) {
5086 nsize = Pbuild[p].nn;
5088 else {
5089 for(comp=0; comp<3; ++comp) {
5090 if(Pbuild[p].ne[comp] < 1) {
5091 bdim[comp] = 1;
5093 else {
5094 bdim[comp] = Pbuild[p].ne[comp];
5097 nsize = bdim[0] * bdim[1] * bdim[2];
5102 if(nsize > 0) {
5104 fprintf(stderr," For part %d, using node %d:\n",pn,nsize);
5106 #if (defined GT_USERD_API_100)
5107 err = USERD_get_var_value_at_specific(vn,
5108 nsize,
5111 var_time_step,
5112 qvals,
5113 FALSE);
5114 #else
5115 err = USERD_get_variable_value_at_specific(vn,
5116 nsize,
5119 var_time_step,
5120 qvals);
5121 #endif
5122 if(err == Z_NOT_IMPLEMENTED) {
5123 fprintf(stderr," Node and element queries not implemented\n");
5124 return(Z_OK);
5126 else if(err == Z_ERR) {
5127 fprintf(stderr," Could not get value\n");
5129 else {
5131 /* For the component, show 1st node, last node, min, max values
5132 *-------------------------------------------------------------*/
5133 if(Varinfo[v].type == Z_SCALAR) {
5134 fprintf(stderr," Scalar value is: %g\n",qvals[0]);
5136 else {
5137 fprintf(stderr," Vector values are: %g %g %g\n",
5138 qvals[0],qvals[1],qvals[2]);
5141 #if (defined GT_USERD_API_100)
5142 if(Varinfo[v].complex) {
5144 err = USERD_get_var_value_at_specific(vn,
5145 nsize,
5148 var_time_step,
5149 qvals,
5150 TRUE);
5152 if(err == Z_ERR) {
5153 fprintf(stderr," Could not get imag value\n");
5155 else {
5157 /* For the component, show 1st node, last node, min, max values
5158 *-------------------------------------------------------------*/
5159 if(Varinfo[v].type == Z_SCALAR) {
5160 fprintf(stderr," Scalar value (imag) is: %g\n",qvals[0]);
5162 else {
5163 fprintf(stderr," Vector values (imag) are: %g %g %g\n",
5164 qvals[0],qvals[1],qvals[2]);
5168 #endif
5175 /* Per_Elem
5176 *---------*/
5177 else {
5178 for(p=0; p<Num_parts; ++p) {
5179 pn = p + 1;
5181 if(Pbuild[p].type != Z_UNSTRUCTURED) {
5183 for(comp=0; comp<3; ++comp) {
5184 if(Pbuild[p].ne[comp] < 1) {
5185 bdim[comp] = 1;
5187 else {
5188 bdim[comp] = Pbuild[p].ne[comp];
5191 bd1 = bdim[0]-1;
5192 if(bd1 < 1) {
5193 bd1 = 1;
5195 bd2 = bdim[1]-1;
5196 if(bd2 < 1) {
5197 bd2 = 1;
5199 bd3 = bdim[2]-1;
5200 if(bd3 < 1) {
5201 bd3 = 1;
5203 nsize = bd1 * bd2 * bd3;
5206 /* Determine cell type
5207 *--------------------*/
5208 num_dims = 3;
5209 for(i=0; i<3; ++i) {
5210 if(bdim[i] == 1) {
5211 --num_dims;
5214 if(num_dims == 3) {
5215 cell_type = Z_HEX08;
5217 else if(num_dims == 2) {
5218 cell_type = Z_QUA04;
5220 else {
5221 cell_type = Z_BAR02;
5225 if(Pbuild[p].type == Z_UNSTRUCTURED) {
5226 e1 = 0;
5227 e2 = Z_MAXTYPE-1;
5229 else {
5230 e1 = e2 = cell_type;
5233 for(et=e1; et<=e2; ++et) {
5235 if(Pbuild[p].type == Z_UNSTRUCTURED) {
5236 nsize = Pbuild[p].ne[et];
5239 if(nsize > 0) {
5242 fprintf(stderr," For part %d, using elem %d of type %s:\n",
5243 pn,nsize,Elem_info[et].name);
5246 #if (defined GT_USERD_API_100)
5247 err = USERD_get_var_value_at_specific(vn,
5248 nsize,
5251 var_time_step,
5252 qvals,
5253 FALSE);
5254 #else
5255 err = USERD_get_variable_value_at_specific(vn,
5256 nsize,
5259 var_time_step,
5260 qvals);
5261 #endif
5263 if(err == Z_NOT_IMPLEMENTED) {
5264 fprintf(stderr," Node and element queries not implemented\n");
5265 return(Z_OK);
5267 else if(err == Z_ERR) {
5268 fprintf(stderr," Could not get value\n");
5270 else {
5271 if(Varinfo[v].type == Z_SCALAR) {
5272 fprintf(stderr," Scalar value is: %g\n",qvals[0]);
5274 else {
5275 fprintf(stderr," Vector values are: %g %g %g\n",
5276 qvals[0],qvals[1],qvals[2]);
5279 #if (defined GT_USERD_API_100)
5280 if(Varinfo[v].complex) {
5282 err = USERD_get_var_value_at_specific(vn,
5283 nsize,
5286 var_time_step,
5287 qvals,
5288 TRUE);
5289 if(err == Z_ERR) {
5290 fprintf(stderr," Could not get imag value\n");
5292 else {
5293 if(Varinfo[v].type == Z_SCALAR) {
5294 fprintf(stderr," Scalar value (imag) is: %g\n",qvals[0]);
5296 else {
5297 fprintf(stderr," Vector values (imag) are: %g %g %g\n",
5298 qvals[0],qvals[1],qvals[2]);
5302 #endif
5311 return(Z_OK);
5315 /*--------------
5316 * exercise_bkup
5317 *--------------*/
5318 static int
5319 exercise_bkup( void )
5321 int err;
5322 FILE *arcfile;
5324 fprintf(stderr,"\n------------ exercise_archive -----------\n");
5326 arcfile = fopen("test.arc","wb");
5327 if(arcfile == (FILE *)NULL) {
5328 fprintf(stderr,"Error: opening test archive file\n");
5329 return(Z_ERR);
5331 err = USERD_bkup(arcfile,Z_SAVE_ARCHIVE);
5332 if(err == Z_ERR) {
5333 fprintf(stderr,"Error: saving to test archive file\n");
5334 return(Z_ERR);
5336 fclose(arcfile);
5338 arcfile = fopen("test.arc","rb");
5339 err = USERD_bkup(arcfile,Z_REST_ARCHIVE);
5340 if(err == Z_ERR) {
5341 fprintf(stderr,"Error: restoring from test archive file\n");
5342 return(Z_ERR);
5345 fprintf(stderr," Archive test completed\n");
5347 fclose(arcfile);
5349 return(Z_OK);
5352 /* -------------------------------------------------------
5353 * threshold_operator1 & 2 can be one of the following
5354 * Z_ELE_FAILED_NONE, - disables checking
5355 * Z_ELE_FAILED_GREATER, - greater than
5356 * Z_ELE_FAILED_LESS, - less than
5357 * Z_ELE_FAILED_EQUAL, - equal
5358 * Z_ELE_FAILED_NOT_EQUAL, - not equal
5359 * Z_ELE_FAILED_MANY - not used
5361 * logic_criteria2
5362 * Z_ELE_FAILED_LOGIC_NONE,
5363 * Z_ELE_FAILED_LOGIC_AND,
5364 * Z_ELE_FAILED_LOGIC_OR,
5365 * Z_ELE_FAILED_LOGIC_MANY
5367 * ------------------------------------------------------ */
5368 int load_fail_defaults(void)
5370 int check_for_failed = FALSE;
5371 int cri1 = 0; /* Criteria1 ELE_FAILED_GREATER, etc */
5372 int cri2 = 0;
5373 int logic_cri2 = 0; /* Logic for criteria 2 ELE_FAILED_LOGIC_NONE, AND, etc */
5374 float val1 = 0.0; /* failure threshold 1 */
5375 float val2= 0.0; /* failure threshold 2 */
5376 char failed_var_name[Z_MXVARIABLEDESC]={EOS};
5378 check_for_failed = USERD_get_uns_failed_params( failed_var_name,
5379 &val1, &val2, &cri1, &cri2,
5380 &logic_cri2 );
5381 if (check_for_failed == TRUE) {
5382 fprintf(stderr,"Failed element criteria info \n");
5383 fprintf(stderr,"Variable name = %s\n",failed_var_name);
5384 fprintf(stderr,"Criteria 1 = %d\n",cri1);
5385 fprintf(stderr,"Criteria 2 = %d\n",cri1);
5386 fprintf(stderr,"Logic criteria = %d\n",logic_cri2);
5387 fprintf(stderr,"Value 1 = %f\n",val1);
5388 fprintf(stderr,"Value 2 = %f\n",val2);
5389 } else {
5390 fprintf(stderr,"No Failed elements\n");
5392 return(Z_OK);
5396 /* End of File */