#define DEBUG 1 #include #include #define MAX_NODES 50000 #define MAX_ELEM 50000 #define MAX_PROPS 10 #define MAX_MATS 16 #define MAX_REGIONS 100 #define MAT_FLG 0 #define MAT_E 1 #define MAT_NU 2 #define MAT_ALPHA 3 #define MAT_DENS 4 #define MAX_LC 10 #define MAT_COF 1 #define ISO_MAT_TYPE 1 #define GAP_MAT_TYPE 7 #define FX 0 #define FY 1 typedef struct _NodalForce { int node_num ; int direct ; int lcase ; double xvalue, yvalue ; } NodalForceRec, *NodalForce ; typedef struct _PressForce { int elem_num ; int face ; int lcase ; double value ; } PressForceRec, *PressForce ; typedef struct _ConvData { int num_mats ; int num_nodes ; int num_elems ; int num_solid ; int num_gap ; int nogap ; int num_regions ; int anal_type ; int internal_mat ; int cur_group ; int group_to_mat[MAX_MATS] ; int mat_to_mat[MAX_MATS] ; int cur_mat ; int cur_load ; int used_flag ; int num_load_case ; double ref_temp ; double mat_props[MAX_PROPS][MAX_MATS] ; double coords[MAX_NODES][2] ; double temp[MAX_NODES] ; int elem_size[MAX_ELEM] ; int elem_nodes[MAX_ELEM][8] ; int elem_mats[MAX_ELEM] ; int elem_nums[MAX_ELEM] ; char fixity[MAX_NODES] ; int num_press_force ; PressForce press_force ; int num_nodal_force ; NodalForce nodal_force ; int accel_flag ; double accelerations[2] ; int num_gap_nodes ; int *gap_nodes ; int *gap_flags ; } ConvDataRec, *ConvData ; #define HASH_TBL_SIZE 500 typedef struct _HashDataRec { int ext_num ; int int_num ; struct _HashDataRec *next ; } HashDataRec, *HashData ; typedef struct _HashTableRec { int cur_num ; HashData table[HASH_TBL_SIZE] ; } HashTableRec, *HashTable ; static ConvDataRec tdata ; static void do_mat_prop() ; static void do_r_const() ; static void do_node() ; static void do_elem() ; static void do_group() ; static void do_actset() ; static void do_dnd() ; static void do_press() ; static void do_ndforce() ; static void do_accel() ; static void do_FRANC_file() ; static int read_temp() ; static void get_cur_mat(); static void find_gap_elems(); static HashTable NewHashTable() ; static int HashInsert() ; static int HashRetrieve() ; main( argc, argv ) int argc ; char *argv[] ; { int i, j ; int total_elems=0 ; char buffer[132] ; char directive[6] ; HashTable node_hash, elem_hash, mat_hash, load_hash ; static int therm_flg = 0 ; FILE *tfd ; /* scan the command line parameters */ tdata.nogap = 0 ; for ( i=1 ; i as the thermal input file\n", argv[i] ) ; fprintf( stderr, "translator exiting\n" ) ; exit(1) ; } else therm_flg = 1 ; } } else if ( strcmp( argv[i], "-nogap" ) == 0 ) { tdata.nogap = 1 ; } /* Check for help flag */ else if ( strcmp( argv[i], "-h" ) == 0 ) { fprintf( stderr, "\n" ) ; fprintf( stderr, "COSMOS to FRANC translator:\n" ) ; fprintf( stderr, "\n" ) ; fprintf( stderr, "cosfranc [-t ] < cosmos.GFM file > franc.inp file\n" ) ; fprintf( stderr, "\n" ) ; fprintf( stderr, "where the -t flag allows you to specify a cosmos .TEM or\n" ) ; fprintf( stderr, ".OUT file that will be used to specify nodal temperatures\n" ) ; fprintf( stderr, "\n" ) ; exit(1) ; } } /* Now initialize tdata */ node_hash = NewHashTable() ; elem_hash = NewHashTable() ; mat_hash = NewHashTable() ; load_hash = NewHashTable() ; tdata.num_mats = 0 ; tdata.num_nodes = 0 ; tdata.num_elems = tdata.num_solid = tdata.num_gap = 0 ; for ( i=0 ; inum_elems ; i++ ) { if (( tdata->elem_size[i] == 6 ) || ( tdata->elem_size[i] == 8 ) || ( tdata->elem_size[i] == 2 )) { num_elem++ ; } else { fprintf( stderr, "Rejecting elem %d with %d nodes\n", i, tdata->elem_size[i] ) ; } } fprintf( stderr, "Number elements on entry is : %d\n", num_elem ) ; #endif if ( !tdata->nogap ) find_gap_elems( tdata, node_hash ) ; /* count the number of elements */ for ( i=0, num_elem=0 ; inum_elems ; i++ ) { if (( tdata->elem_size[i] == 6 ) || ( tdata->elem_size[i] == 8 ) || ( tdata->elem_size[i] == 2 )) { num_elem++ ; } #ifdef DEBUG else { fprintf( stderr, "Rejecting elem %d with %d nodes\n", i, tdata->elem_size[i] ) ; } #endif } /* write out the header */ printf( "franc input file\n" ) ; printf( "%d %d %d %d\n", tdata->num_nodes, num_elem, tdata->num_mats, tdata->anal_type ) ; /* write out materials (isotropic only right now) */ for ( i=0 ; inum_mats ; i++ ) { printf( "%5d %9.2e %9.2e %9.2e %9.2e %9.2e\n", (int)tdata->mat_props[MAT_FLG][i], tdata->mat_props[MAT_E][i], tdata->mat_props[MAT_NU][i], (double)1.0, (double)1.0, tdata->mat_props[MAT_DENS][i] ) ; } /* now the element connectivity */ for ( i=0, cur=0 ; inum_elems ; i++ ) { if ( tdata->elem_size[i] == 6 ) { for ( j=0 ; j<8 ; j++ ) nodes[j] = HashRetrieve(node_hash,tdata->elem_nodes[i][j]) + 1 ; printf( "%5d %4d%5d%5d%5d%5d%5d%5d\n", cur+1, tdata->elem_mats[i], nodes[0], nodes[4], nodes[1], nodes[5], nodes[2], nodes[7] ) ; cur++ ; } else if ( tdata->elem_size[i] == 8 ) { for ( j=0 ; j<8 ; j++ ) nodes[j] = HashRetrieve(node_hash,tdata->elem_nodes[i][j]) + 1 ; printf( "%5d %4d%5d%5d%5d%5d%5d%5d%5d%5d\n", cur+1, tdata->elem_mats[i], nodes[0], nodes[4], nodes[1], nodes[5], nodes[2], nodes[6], nodes[3], nodes[7] ) ; cur++ ; } else if ( tdata->elem_size[i] == 2 ) { for ( j=0 ; j<4 ; j++ ) nodes[j] = HashRetrieve(node_hash,tdata->elem_nodes[i][j]) + 1 ; printf( "%5d %4d%5d%5d%5d%5d%5d%5d\n", cur+1, tdata->elem_mats[i], nodes[0], (int)1, nodes[1], nodes[2], (int)1, nodes[3] ) ; cur++ ; } /* else { fprintf( stderr, "Skipping element %d %d\n", i, tdata->elem_size[i] ) ; } */ } /* now the nodal coordinates */ /* for ( i=0 ; i<50 ; i++ ) */ for ( i=0 ; inum_nodes ; i++ ) printf( "%5d %e %e\n", i+1, tdata->coords[i][0], tdata->coords[i][1] ) ; /* nodal fixity */ num_fix = 0 ; for ( i=0 ; inum_nodes ; i++ ) { if ( tdata->fixity[i] != 0 ) num_fix++ ; } if ( num_fix > 0 ) { printf( "AFIXITY\n" ) ; printf( "%d\n", num_fix ) ; for ( i=0 ; inum_nodes ; i++ ) { if ( tdata->fixity[i] != 0 ) { printf( "%d %d 0.0\n", i+1, tdata->fixity[i] ) ; } } } /* pressure loads */ if ( tdata->num_press_force ) { printf( "APRESS\n" ) ; printf( "%d\n", tdata->num_press_force ) ; for ( i=0 ; inum_press_force ; i++ ) { printf( "%d %d %d %f\n", tdata->press_force[i].elem_num, tdata->press_force[i].face, tdata->press_force[i].lcase, tdata->press_force[i].value ) ; } } /* nodal loads */ if ( tdata->num_nodal_force ) { /* first we combine x and y loads */ num_load = tdata->num_nodal_force ; for ( i=0 ; inum_nodal_force ; i++ ) { if ( tdata->nodal_force[i].lcase != -1 ) { for ( j=i+1 ; jnum_nodal_force ; j++ ) { if (( tdata->nodal_force[i].node_num == tdata->nodal_force[j].node_num ) && ( tdata->nodal_force[i].lcase == tdata->nodal_force[j].lcase )) { tdata->nodal_force[i].xvalue += tdata->nodal_force[j].xvalue ; tdata->nodal_force[i].yvalue += tdata->nodal_force[j].yvalue ; tdata->nodal_force[j].lcase = -1 ; num_load-- ; } } } } /* now write the tdata */ printf( "ALOADS\n" ) ; printf( "%d\n", num_load ) ; for ( i=0 ; inum_nodal_force ; i++ ) { if ( tdata->nodal_force[i].lcase != -1 ) { printf( "%d %d %g %g\n", tdata->nodal_force[i].node_num+1, tdata->nodal_force[i].lcase, tdata->nodal_force[i].xvalue, tdata->nodal_force[i].yvalue ) ; } } } /* accelerations */ if ( tdata->accel_flag ) { tdata->num_load_case += 1 ; printf( "AACCEL\n" ) ; printf( "%d %lg %lg\n", tdata->num_load_case, tdata->accelerations[0], tdata->accelerations[1] ) ; } /* nodal temperatures */ if ( num_temp > 0 ) tdata->num_load_case += 1 ; if ( tdata->ref_temp != 0.0 ) { printf( "AREFTMP\n" ) ; printf( "%d %lf\n", tdata->num_load_case, tdata->ref_temp ) ; } num_temp = 0 ; for ( i=0 ; inum_nodes ; i++ ) { if ( tdata->temp[i] != 0.0 ) num_temp++ ; } if ( num_temp > 0 ) { printf( "ANODTMP\n" ) ; printf( "%d %d %f\n", num_temp, tdata->num_load_case, tdata->mat_props[MAT_ALPHA][1] ) ; for ( i=0 ; inum_nodes ; i++ ) { if ( tdata->temp[i] != 0.0 ) { printf( "%d %f\n", i+1, tdata->temp[i] ) ; } } } } static void do_press( buf, tdata, elem_hash ) char *buf ; ConvData tdata ; HashTable elem_hash ; { int num, ext_num, face, cur ; double value ; char direct[10] ; sscanf( buf, "%s %d %lf %d", direct, &ext_num, &value, &face ) ; num = HashRetrieve( elem_hash, ext_num ) ; if ((tdata->elem_size[num] == 6) && (face == 4)) { face = 3 ; } cur = tdata->num_press_force ; tdata->press_force[cur].elem_num = num ; tdata->press_force[cur].face = face ; tdata->press_force[cur].lcase = tdata->cur_load ; tdata->press_force[cur].value = value ; tdata->num_press_force++ ; } static void do_ndforce( buf, tdata, node_hash ) char *buf ; ConvData tdata ; HashTable node_hash ; { int num, nd_num, cur ; double value ; char direct[10], dir[5] ; sscanf( buf, "%s %d %s %lf", direct, &nd_num, dir, &value ) ; num = HashRetrieve( node_hash, nd_num ) ; cur = tdata->num_nodal_force ; tdata->nodal_force[cur].node_num = num ; tdata->nodal_force[cur].lcase = tdata->cur_load ; if ( strcmp( dir, "FX" ) == 0 ) { tdata->nodal_force[cur].xvalue = value ; } else if ( strcmp( dir, "FY" ) == 0 ) { tdata->nodal_force[cur].yvalue = value ; } else { fprintf( stderr, "Unrecognized Nodal Force direction : %s\n", dir ) ; fprintf( stderr, "%s\n", buf ) ; exit( 1 ) ; } tdata->num_nodal_force++ ; } static void do_dnd( buf, tdata, node_hash ) char *buf ; ConvData tdata ; HashTable node_hash ; { int num, ext_num ; char direct[10], code[10] ; sscanf( buf, "%s %d %s", direct, &ext_num, code ) ; num = HashRetrieve( node_hash, ext_num ) ; if (( strcmp(code,"UX") == 0 ) || ( strcmp(code,"SX") == 0 )) tdata->fixity[num] |= 0x1 ; else if (( strcmp(code,"UY") == 0 ) || ( strcmp(code,"SY") == 0 )) tdata->fixity[num] |= 0x2 ; } static void do_actset( buf, tdata, mat_hash, load_hash ) char *buf ; ConvData tdata ; HashTable mat_hash ; HashTable load_hash ; { int reg_num, val, int_mat ; char direct[10], code[10] ; sscanf( buf, "%s %s %d", direct, code, &val ) ; if ( strcmp( code, "MP" ) == 0 ) { tdata->cur_mat = val ; tdata->internal_mat = -1 ; } else if ( strcmp( code, "EG" ) == 0 ) { tdata->cur_group = val ; tdata->internal_mat = -1 ; } else if ( strcmp( code, "LC" ) == 0 ) { if ( tdata->used_flag ) { tdata->cur_load = HashRetrieve( load_hash, val ) ; if ( tdata->cur_load < 0 ) { tdata->cur_load = HashInsert( load_hash, val ) ; tdata->num_load_case++ ; tdata->used_flag = 0 ; } tdata->cur_load++ ; } } } static void do_group( buf, tdata, mat_hash ) char *buf ; ConvData tdata ; HashTable mat_hash ; { int options[7], num, int_num ; char direct[10], type[10] ; sscanf( buf, "%s %d %s %d %d %d", direct, &num, type, &options[0], &options[1], &options[2] ) ; int_num = tdata->group_to_mat[num] ; if ( tdata->mat_props[MAT_FLG][int_num] == 0 ) { if ( strcmp( type, "PLANE2D" ) == 0 ) tdata->mat_props[MAT_FLG][int_num] = ISO_MAT_TYPE ; else if ( strcmp( type, "GAP" ) == 0 ) tdata->mat_props[MAT_FLG][int_num] = GAP_MAT_TYPE ; } /* check the analysis type */ if ( strcmp( type, "PLANE2D" ) == 0 ) { switch ( options[2] ) { case 0 : tdata->anal_type = 1 ; break ; case 1 : tdata->anal_type = 0 ; break ; case 2 : tdata->anal_type = 2 ; break ; } } } static void do_elem( buf, tdata, elem_hash ) char *buf ; ConvData tdata ; HashTable elem_hash ; { int num, int_num, mat, int_mat, num_nodes, n[8], i ; char direct[10], type[10] ; sscanf( buf, "%s %d %s %d %d %d %d %d %d %d %d %d %d", direct, &num, type, &mat, &num_nodes, &n[0], &n[1], &n[2], &n[3], &n[4], &n[5], &n[6], &n[7] ) ; /* store the info for this element */ get_cur_mat( tdata ) ; if ( num_nodes == 2 ) { tdata->gap_nodes[tdata->num_gap_nodes] = n[0] ; tdata->gap_nodes[tdata->num_gap_nodes+1] = n[1] ; tdata->gap_flags[tdata->num_gap_nodes] = tdata->internal_mat ; tdata->num_gap_nodes += 2 ; } else { /* hash this node number to get an internal number */ int_num = HashInsert( elem_hash, num ) ; /* check to see if we have enough room */ if ( tdata->num_elems >= MAX_ELEM ) { fprintf( stderr, "Too many elements!\n" ) ; fprintf( stderr, "Change the size of MAX_ELEM, and try again\n" ) ; exit(0) ; } if ( n[2] == n[3] ) { tdata->elem_size[int_num] = 6 ; } else { tdata->elem_size[int_num] = 8 ; } for ( i=0 ; i<8 ; i++ ) tdata->elem_nodes[int_num][i] = n[i] ; tdata->num_solid++ ; tdata->elem_mats[int_num] = tdata->internal_mat ; tdata->elem_nums[int_num] = num ; tdata->num_elems++ ; } } static void do_node( buf, tdata, node_hash ) char *buf ; ConvData tdata ; HashTable node_hash ; { int num, int_num ; char direct[10] ; double x, y ; sscanf( buf, "%s %d %lf %lf", direct, &num, &x, &y ) ; /* hash this node number to get an internal number */ int_num = HashInsert( node_hash, num ) ; /* check to see if we have room */ if ( tdata->num_nodes >= MAX_NODES ) { fprintf( stderr, "Too many nodes for translator! \n" ) ; fprintf( stderr, "change the parameter MAX_NODES, and try again\n" ) ; exit(0) ; } /* store the coordinates */ tdata->coords[int_num][0] = x ; tdata->coords[int_num][1] = y ; tdata->num_nodes++ ; } static void do_accel( buf, tdata ) char *buf ; ConvData tdata ; { int num, int_num ; char direct[10] ; double x, y, z ; sscanf( buf, "%s %lf %lf %lf", direct, &x, &y, &z ) ; if ( strcmp( direct, "OMEGA" ) == 0 ) { tdata->accelerations[0] = y ; tdata->accel_flag = 1 ; } else if ( strcmp( direct, "ACCEL" ) == 0 ) { tdata->accelerations[1] = y ; tdata->accel_flag = 1 ; } } static void do_mat_prop( buf, tdata, mat_hash ) char *buf ; ConvData tdata ; HashTable mat_hash ; { int num, int_num ; char direct[10],code[10] ; double value ; sscanf( buf, "%s %d %s %lf", direct, &num, code, &value ) ; int_num = tdata->mat_to_mat[num] ; /* process the material property: currently the only properties used are EX, NUXY, ALPHA, and DENS. All materials are assumed to be isotropic */ if ( strcmp( code, "EX" ) == 0 ) { tdata->mat_props[MAT_E][int_num] = value ; } else if ( strcmp( code, "NUXY" ) == 0 ) { tdata->mat_props[MAT_NU][int_num] = value ; } else if ( strcmp( code, "ALPX" ) == 0 ) { tdata->mat_props[MAT_ALPHA][int_num] = value ; } else if ( strcmp( code, "DENS" ) == 0 ) { tdata->mat_props[MAT_DENS][int_num] = value ; } } static void do_r_const( buf, tdata ) char *buf ; ConvData tdata ; { int num, junk, int_num, first, last ; char direct[10] ; double value[10] ; sscanf( buf, "%s %d %d %d %d %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf", direct, &num, &junk, &first, &last, &value[0], &value[1], &value[2], &value[3], &value[4], &value[5], &value[6], &value[7], &value[8], &value[9] ) ; int_num = tdata->group_to_mat[num] ; /* if this is a gap element material type, then look for constant 2, which is the friction coefficient */ if ( tdata->mat_props[MAT_FLG][int_num] == GAP_MAT_TYPE ) { if (( first <= 2 ) && ( last >= 2 )) { tdata->mat_props[MAT_COF][int_num] = value[2-first] ; } } } static void get_cur_mat( tdata ) ConvData tdata ; { int mat ; if ( tdata->internal_mat >= 0 ) return ; mat = tdata->group_to_mat[tdata->cur_group] ; if ( mat >= 0 ) { if ( tdata->mat_props[MAT_FLG][mat] == GAP_MAT_TYPE ) { tdata->internal_mat = mat+1 ; return ; } } mat = tdata->mat_to_mat[tdata->cur_mat] ; if ( mat >= 0 ) { tdata->internal_mat = mat+1 ; return ; } fprintf( stderr, "GET_CUR_MAT: cannot determine material\n" ) ; tdata->internal_mat = 0 ; } static void find_gap_elems( tdata, node_hash ) ConvData tdata ; HashTable node_hash ; { int i, j, k, l, m, nnds, cur_node, found ; int next, prev, nodes[4] ; int first, second, third ; double norm[2], vect[3], dot ; /* We need to link-up the two-noded gap elements into 6-noded elements. To do this we look for an element that has adjacent nodes that are the same as two of the gap element nodes */ for ( i=0 ; inum_elems ; i++ ) { if ( tdata->elem_size[i] == 6 ) nnds = 3 ; else if ( tdata->elem_size[i] == 8 ) nnds = 4 ; else nnds = 0 ; for ( j=0 ; jelem_nodes[i][j] ; found = 0 ; for ( k=0 ; (knum_gap_nodes)&&(!found) ; k += 2 ) { if ( cur_node == tdata->gap_nodes[k] ) { found = 1 ; next = (j+1) % nnds ; next = tdata->elem_nodes[i][next] ; /* look for the next node in the list */ for ( l=0 ; lnum_gap_nodes ; l += 2 ) { if ( next == tdata->gap_nodes[l] ) { fprintf( stderr, "Found Gap Elem : %d %d %d %d\n", cur_node, tdata->gap_nodes[k+1], next, tdata->gap_nodes[l+1] ) ; tdata->elem_size[tdata->num_elems] = 2 ; tdata->elem_mats[tdata->num_elems] = tdata->gap_flags[k] ; nodes[0] = cur_node ; nodes[1] = next ; nodes[2] = tdata->gap_nodes[l+1] ; nodes[3] = tdata->gap_nodes[k+1] ; /* now we need to order the nodes in ccw order */ first = HashRetrieve( node_hash, cur_node ) ; second = HashRetrieve( node_hash, next ) ; norm[0] = tdata->coords[second][1] - tdata->coords[first][1] ; norm[1] = tdata->coords[first][0] - tdata->coords[second][0] ; third = (j+2) % nnds ; third = HashRetrieve( node_hash, tdata->elem_nodes[i][third] ) ; vect[0] = tdata->coords[third][0] - tdata->coords[first][0] ; vect[1] = tdata->coords[third][1] - tdata->coords[first][1] ; dot = norm[0] * vect[0] + norm[1] * vect[1] ; if ( dot >= 0.0 ) { for ( m=0 ; m<4 ; m++ ) tdata->elem_nodes[tdata->num_elems][m] = nodes[m] ; } else { tdata->elem_nodes[tdata->num_elems][0] = nodes[1] ; tdata->elem_nodes[tdata->num_elems][1] = nodes[0] ; tdata->elem_nodes[tdata->num_elems][2] = nodes[3] ; tdata->elem_nodes[tdata->num_elems][3] = nodes[2] ; } tdata->num_elems++ ; } } } } } } } #define BLEN 132 static int read_temp( tfd, tdata, node_hash ) FILE *tfd ; ConvData tdata ; HashTable node_hash ; { int node, found = 0 ; int int_num ; char buff[BLEN], *ptr ; float ref_temp, temp ; /* assume we are reading a PC-Version of the .OUT file */ while ( !found ) { if ( fgets( buff, BLEN, tfd ) != NULL ) { if ( strstr( buff, "Thermal Loading Information" ) != NULL ) { found = 1 ; break ; } } else { fprintf( stderr, "Cannot find temperature information in the file\n" ) ; break ; } } /* if we get here and we have found the info, first get the reference temperature */ if ( found ) { fgets( buff, BLEN, tfd ) ; fgets( buff, BLEN, tfd ) ; ptr = strstr( buff, "=" ) ; ptr++ ; sscanf( ptr, "%f", &ref_temp ) ; tdata->ref_temp = ref_temp ; /* Now read the node number and temperature pairs */ fgets( buff, BLEN, tfd ) ; /* blank line */ fgets( buff, BLEN, tfd ) ; /* blank line */ fgets( buff, BLEN, tfd ) ; /* labels */ fgets( buff, BLEN, tfd ) ; /* blank line */ fgets( buff, BLEN, tfd ) ; while ( sscanf( buff, "%d %f", &node, &temp ) == 2 ) { int_num = HashRetrieve( node_hash, node ) ; if ( int_num < 0 ) { fprintf( stderr, "Illegal node number <%d> found in nodal temperature description\n", int_num ) ; } else tdata->temp[int_num] = temp ; fgets( buff, BLEN, tfd ) ; } return( 1 ) ; } /* if we get here then this file is probably not in the PC format. rewind the file and try to look for the Workstation stuff */ fprintf( stderr, "Rescanning assuming the workstation version...\n" ) ; rewind( tfd ) ; while ( !found ) { if ( fgets( buff, BLEN, tfd ) != NULL ) { if ( strstr( buff, "Node Temperature" ) != NULL ) { found = 1 ; break ; } } else { fprintf( stderr, "Cannot find temperature information in the file\n" ) ; break ; } } /* if we found things, then read the node temp tdata */ if ( found ) { int i, j=0, num, nd[4] ; float tmp[4] ; fgets( buff, BLEN, tfd ) ; /* blank line */ while ( fgets( buff, BLEN, tfd ) != NULL ) { if (( num = sscanf( buff, "%d %f %d %f %d %f %d %f", &nd[0], &tmp[0], &nd[1], &tmp[1], &nd[2], &tmp[2], &nd[3], &tmp[3] )) >= 2 ) { num /= 2 ; for ( i=0 ; i found in nodal temperature description\n", int_num ) ; } else { j++ ; tdata->temp[int_num] = tmp[i] ; } } } } return( 1 ) ; } return( 0 ) ; } static HashTable NewHashTable() { HashTable table ; table = (HashTable)calloc(1,sizeof(HashTableRec)) ; table->cur_num = 0 ; return(table) ; } static int HashInsert( tbl, ext_num ) HashTable tbl ; int ext_num ; { int indx ; HashData tdata ; indx = ext_num % HASH_TBL_SIZE ; if ( tbl->table[indx] ) { for ( tdata = tbl->table[indx] ; tdata != 0 ; tdata = tdata->next ) { if ( tdata->ext_num == ext_num ) return( tdata->int_num ) ; } } /* insert a new entry */ tdata = (HashData)calloc(1,sizeof(HashDataRec)) ; tdata->next = tbl->table[indx] ; tdata->ext_num = ext_num ; tdata->int_num = tbl->cur_num ; tbl->cur_num++ ; tbl->table[indx] = tdata ; return(tdata->int_num) ; } static int HashRetrieve( tbl, ext_num ) HashTable tbl ; int ext_num ; { int indx ; HashData tdata ; indx = ext_num % HASH_TBL_SIZE ; if ( tbl->table[indx] == 0 ) return(-1) ; for ( tdata = tbl->table[indx] ; tdata != 0 ; tdata = tdata->next ) { if ( tdata->ext_num == ext_num ) return( tdata->int_num ) ; } return( -1 ) ; } static int HashEquivalent( tbl, ext_num1, ext_num2 ) HashTable tbl ; int ext_num1, ext_num2 ; { int indx1, indx2 ; HashData tdata, tdata1 = 0, tdata2 = 0 ; /* look for the first one */ indx1 = ext_num1 % HASH_TBL_SIZE ; if ( tbl->table[indx1] ) { for ( tdata = tbl->table[indx1] ; tdata != 0 ; tdata = tdata->next ) { if ( tdata->ext_num == ext_num1 ) { tdata1 = tdata ; break ; } } } /* else insert the first one */ if ( !tdata1 ) { tdata1 = (HashData)calloc(1,sizeof(HashDataRec)) ; tdata1->next = tbl->table[indx1] ; tdata1->ext_num = ext_num1 ; tdata1->int_num = tbl->cur_num ; tbl->cur_num++ ; tbl->table[indx1] = tdata1 ; } /* now look for the second one */ indx2 = ext_num2 % HASH_TBL_SIZE ; if ( tbl->table[indx2] ) { for ( tdata = tbl->table[indx2] ; tdata != 0 ; tdata = tdata->next ) { if ( tdata->ext_num == ext_num2 ) { tdata->int_num = tdata1->int_num ; return( tdata1->int_num ) ; } } } /* else insert the first one */ if ( !tdata2 ) { tdata2 = (HashData)calloc(1,sizeof(HashDataRec)) ; tdata2->next = tbl->table[indx2] ; tdata2->ext_num = ext_num2 ; tdata2->int_num = tdata1->int_num ; tbl->table[indx2] = tdata2 ; } return(tdata1->int_num) ; }