/*******************************************************************************************\ ####### ##### ###### ##### ##### ##### ###### ###### # # # # # # # # # # # # # # # ## ## # # # # # # # # # # # # # # # # ##### # # ##### # # # # ##### ##### # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ##### ###### ####### ##### ##### # ###### # # Converter from T3d to OOFEM Copyright: Daniel Rypl 1998 - 2015 Czech Technical University in Prague Faculty of Civil Engineering, Department of Mechanics Thakurova 7, 166 29 Prague, Czech Republic email: drypl@fsv.cvut.cz \*******************************************************************************************/ #include #include #include #include #include #if defined(_WIN32) || defined(_WIN64) #pragma warning(disable : 4996) // to avoid warnings for unsafe functions like fopen, etc #define strcasecmp _stricmp #define strncasecmp _strnicmp #endif #define VERSION "2.7" /* caution: this version does not process property specification within boundary entity output on all 2D and 3D elements; this fact should not influence functionality */ /* note: since the ctrl file is processed before t3d output file, all relevant (loaded, supported, etc.) entities are instanciated (even those that are not detected from t3d output because there is no node on it (single element entity) */ #define FILE_NAME_SIZE 128 #define BUFFER_SIZE 65536 #define KEY_SIZE 32 #define SEPARATOR " \n\r" #define REMARK '#' #define PROPERTY_ENTITY 0 #define VERTEX_ENTITY 1 #define CURVE_ENTITY 2 #define SURFACE_ENTITY 3 #define REGION_ENTITY 4 #define PATCH_ENTITY 5 #define SHELL_ENTITY 6 #define INTERFACE_ENTITY 7 #define LINEAR 1 #define QUADRATIC 2 #define TRI_TETRA 3 #define QUAD_HEXA 4 #define GENERAL_ERROR 1 #define LONG_NAME_ERROR 2 #define FILE_OPEN_ERROR 3 #define FILE_READ_ERROR 4 #define FILE_WRITE_ERROR 5 #define MEMORY_ERROR 6 #define DEFAULT_FIRST /* #define DEFAULT_LAST */ #define SINGULARITY /* support for singularity spheres */ #ifdef SINGULARITY #define ALL_NODES_INSIDE /* all nodes must be inside singularity sphere, otherwise only one is enough */ #define ONLY_LINEAR_NODES /* only linear nodes are considered for higher order elements */ #endif typedef enum logic{ NO = 0, YES = 1 }logic; typedef struct list_rec list_rec; struct list_rec{ void *item; list_rec *next; }; typedef struct point_rec point_rec; struct point_rec{ double x, y, z; }; typedef struct lcs_rec lcs_rec; struct lcs_rec{ int entity_type; long entity_id; int lcs_x, lcs_y; point_rec ref_vector; }; typedef struct singularity_rec singularity_rec; struct singularity_rec{ long node_id; point_rec center; double radius; long elems; }; typedef struct entity_rec entity_rec; typedef struct entities_rec entities_rec; struct entity_rec{ long id; int type; logic selected; list_rec *node_prop_list; list_rec *elem_prop_list; char *elem_type; char *edge_type; char *tria_type; char *quad_type; char *tetra_type; char *pyram_type; char *wedge_type; char *hexa_type; list_rec *bload_id_list; list_rec *bcode_id_list; char *node_type; /* non NULL if special type, eg. rigidarmnode, etc. */ long first_node; long nodes; long elems; logic on_output; list_rec *curve_id_list; /* list of curves sharing vertex */ list_rec *singularity_list; /* list of protecting spheres */ lcs_rec *lcs; logic interface_1D; point_rec *dirs; }; struct entities_rec{ list_rec *id; /* list of ids of excluded entities */ int type; logic selected; list_rec *node_prop_list; list_rec *elem_prop_list; char *elem_type; char *edge_type; char *tria_type; char *quad_type; char *tetra_type; char *pyram_type; char *wedge_type; char *hexa_type; list_rec *bload_id_list; list_rec *bcode_id_list; char *node_type; list_rec *singularity_list; lcs_rec *lcs; }; /* interface_1D is used to create 1D interface between corresponding nodes on pair of vertices, curves, surfaces, patches, shells; note that 1D interface between pairs of vertices can be created also using t3d 1D interface element with normal specification supplied via elemprop specification */ typedef struct interface_1D_rec interface_1D_rec; struct interface_1D_rec{ int type; /* 0 - dir, 1 - tan on curve, 2 - tan on surface, 3 - nor on surface, 4 - nor on curve */ logic selected; entity_rec *master, *slave; point_rec vector; list_rec *elem_prop_list; }; static list_rec *vertex_list = NULL; static list_rec *curve_list = NULL; static list_rec *surface_list = NULL; static list_rec *patch_list = NULL; static list_rec *shell_list = NULL; static list_rec *region_list = NULL; static list_rec *interface_list = NULL; static list_rec *interface_1D_list = NULL; static list_rec *vertices_list = NULL; static list_rec *curves_list = NULL; static list_rec *surfaces_list = NULL; static list_rec *patches_list = NULL; static list_rec *shells_list = NULL; static list_rec *regions_list = NULL; static list_rec *interfaces_list = NULL; static list_rec *property_list = NULL; static list_rec *string_list = NULL; static list_rec *id_list = NULL; static list_rec *singularity_list = NULL; static list_rec *lcs_list = NULL; static logic vertex_select = NO; static logic curve_select = NO; static logic surface_select = NO; static logic patch_select = NO; static logic shell_select = NO; static logic region_select = NO; static logic interface_select = NO; static logic multi_select = NO; static logic property_select = NO; static logic entity_select = NO; static logic node_elem_select = NO; static logic interface_1D_select = NO; static long *node_flag = NULL; static long *con_node1 = NULL; static long *con_node2 = NULL; typedef struct node_rec node_rec; #if 0 typedef struct edge_rec edge_rec; typedef struct face_rec face_rec; typedef struct quad_rec quad_rec; typedef struct tetra_rec tetra_rec; typedef struct pyram_rec pyram_rec; typedef struct wedge_rec wedge_rec; typedef struct hexa_rec hexa_rec; #endif struct node_rec{ double x, y, z; entity_rec *entity; }; #if 0 /* boundary info is not stored ! */ struct edge_rec{ long node_id[2]; long midnode_id; entity_rec *entity; }; struct face_rec{ long node_id[3]; long midnode_id[3]; // long bubblenode_id; entity_rec *entity; }; struct quad_rec{ long node_id[4]; long midnode_id[4]; // long bubblenode_id; entity_rec *entity; }; struct tetra_rec{ long node_id[4]; long midnode_id[6]; // long bubblenode_id; entity_rec *entity; }; struct pyram_rec{ long node_id[5]; long midnode_id[8]; // long bubblenode_id; entity_rec *entity; }; struct wedge_rec{ long node_id[6]; long midnode_id[9]; // long bubblenode_id; entity_rec *entity; }; struct hexa_rec{ long node_id[8]; long midnode_id[12]; // long bubblenode_id; entity_rec *entity; }; #endif static node_rec *fe_nodes = NULL; #if 0 static edge_rec *fe_edges = NULL; static face_rec *fe_faces = NULL; static quad_rec *fe_quads = NULL; static tetra_rec *fe_tetras = NULL; static pyram_rec *fe_pyrams = NULL; static wedge_rec *fe_wedges = NULL; static hexa_rec *fe_hexas = NULL; #endif /* IMPORTANT: do not use VERTEX, CURVE, ..., INTERFACE keys instead of VERTEX_ENTITY, ..., INTERFACE_ENTITY ids */ static enum keyword{ CANCEL, VERTEX, CURVE, SURFACE, PATCH, SHELL, REGION, INTERFACE, ALL, EXCEPT, PROPERTY, NODEPROP, ELEMPROP, NODETYPE, ELEMTYPE, EDGETYPE, TRIATYPE, QUADTYPE, TETRATYPE, HEXATYPE, BLOAD, BOUNDARYLOAD, /* same as bload */ BCODE, BOUNDARYCODE, /* same as bcode */ LCSPRIMARY, // LCSSECONDARY, UVW, VWU, WUV, VUW, WVU, UWV, SINGULARNODE, SINGULARPOINT, INTERFACE1D, DIR, TAN, NOR, /* to ensure compatibility with t3d2poofem */ ELEMWEIGHT, EDGEWEIGHT, TRIAWEIGHT, QUADWEIGHT, TETRAWEIGHT, PYRAMWEIGHT, WEDGEWEIGHT, HEXAWEIGHT, WIDTH, PARTITION, MASTER, KEY_NUM }key, last_key = KEY_NUM; static char keyword[KEY_NUM][KEY_SIZE] = { "CANCEL", "VERTEX", "CURVE", "SURFACE", "PATCH", "SHELL", "REGION", "INTERFACE", "ALL", "EXCEPT", "PROPERTY", "NODEPROP", "ELEMPROP", "NODETYPE", "ELEMTYPE", "EDGETYPE", "TRIATYPE", "QUADTYPE", "TETRATYPE", "HEXATYPE", "BLOAD", "BOUNDARYLOAD", "BCODE", "BOUNDARYCODE", "LCSPRIMARY", // "LCSSECONDARY", "UVW", "VWU", "WUV", "VUW", "WVU", "UWV", "SINGULARNODE", "SINGULARPOINT", "INTERFACE1D", "DIR", "TAN", "NOR", /* to ensure compatibility with t3d2poofem */ "ELEMWEIGHT", "EDGEWEIGHT", "TRIAWEIGHT", "QUADWEIGHT", "TETRAWEIGHT", "PYRAMWEIGHT", "WEDGEWEIGHT", "HEXAWEIGHT", "WIDTH", "PARTITION", "MASTER" }; typedef enum key_case{ MIXED_CASE, UPPER_CASE, LOWER_CASE }key_case; #define KEY_CASE UPPER_CASE static char line_buffer[BUFFER_SIZE], temp_buffer[BUFFER_SIZE]; static FILE *active_in_file = NULL, *active_out_file = NULL; static list_rec * add_item_to_list_head(list_rec *any_list, void *item); static list_rec * deep_destroy_list(list_rec *any_list); static list_rec * destroy_list(list_rec *any_list); static list_rec * reverse_list(list_rec *any_list); static long get_list_size(list_rec *any_list); static char * get_next_record(char *err_msg); static char * get_next_relevant_record(char *err_msg); static char * get_first_token(char *err_msg); static char * get_next_token(char *err_msg); static int get_token_key(char *token, char keyword[1][KEY_SIZE], int keynum); long get_next_int(char *err_msg); double get_next_fpn(char *err_msg); long get_int_from_token(char *token); double get_fpn_from_token(char *token); static void write_current_record(char *err_msg); static void read_write_next_relevant_record(char *in_err_msg, char *out_err_msg); static void read_write_unrelevant_records(char *in_err_msg, char *out_err_msg); static void read_write_until_next_relevant_record(char *in_err_msg, char *out_err_msg); static long * get_id(list_rec *id_list, long id); static long * create_id(long id); static entity_rec * get_entity_id(list_rec *entity_list, long id); static entity_rec * create_entity_id(long id, int type); static entities_rec * create_entities(int type); static entity_rec * create_missing_entity_id(long id, int entity_type); static singularity_rec * create_singularity(long node_id, double x, double y, double z, double radius); static interface_1D_rec * create_interface_1D(entity_rec *master, entity_rec *slave, int type, double x, double y, double z); static lcs_rec * create_lcs(int entity_type, long entity_id, int lcs_x, int lcs_y, double x, double y, double z); static void process_entity(entity_rec *ent, int entity_type); static void process_entity_list(list_rec **entity_list, list_rec **entities_list, char *entity_name, int entity_type); static void process_entities_list(entities_rec *ents, char *entity_name, int entity_type); static void deselect_entity_list(list_rec *entity_list); static void deselect_entities_list(list_rec *entities_list); static void deselect_interface_1D_list(void); static void reverse_node_elem_entity_list(list_rec *entity_list); static void apply_node_properties(char *string); static void apply_node_properties_entity_list(list_rec *entity_list, char *string); static void apply_node_properties_entities_list(list_rec *entities_list, char *string); static void apply_elem_properties(char *string); static void apply_elem_properties_entity_list(list_rec *entity_list, char *string); static void apply_elem_properties_entities_list(list_rec *entities_list, char *string); static void apply_elem_properties_interface_1D_list(char *string); static void apply_node_type(char *string); static void apply_node_type_entity_list(list_rec *entity_list, char *string, char *entity_name); static void apply_node_type_entities_list(list_rec *entities_list, char *string, char *entity_name); static void apply_elem_type(char *string); static void apply_elem_type_entity_list(list_rec *entity_list, char *string, char *entity_name); static void apply_elem_type_entities_list(list_rec *entities_list, char *string, char *entity_name); static void apply_elem_bload(long *ident); static void apply_elem_bload_entity_list(list_rec *entity_list, long *ident); static void apply_elem_bload_entities_list(list_rec *entities_list, long *ident); static void apply_elem_bcode(long *ident); static void apply_elem_bcode_entity_list(list_rec *entity_list, long *ident); static void apply_elem_bcode_entities_list(list_rec *entities_list, long *ident); static void apply_singularity(singularity_rec *singularity); static void apply_singularity_entity_list(list_rec *entity_list, singularity_rec *singularity); static void apply_singularity_entities_list(list_rec *entities_list, singularity_rec *singularity); static void apply_lcs(lcs_rec *lcs); static void apply_lcs_entity_list(list_rec *entity_list, lcs_rec *lcs); static void apply_lcs_entities_list(list_rec *entities_list, lcs_rec *lcs); static logic get_linear_edge_flag(long node1_id, long node2_id, long curve_id); static logic get_quadratic_edge_flag(long midnode_id); static logic check_inside_singularity(entity_rec *entity, int nodes, long *node_array); static logic write_fictitious_csect(char *string, int csect, char *entity_name, long entity_id, FILE *file); static void destroy_entity_list(list_rec *entity_list); static void destroy_entities_list(list_rec *entities_list); static void destroy_interface_1D_list(void); static void check_entity_list(list_rec *entity_list, char *entity_name); static char * store_string(char *string); static void exit_error_message(char *message, int exit_code, int line); #define error_message(MSG, CODE) exit_error_message(MSG, CODE, __LINE__) static logic warning = NO; int main(int argc, char **argv) { long nodes = 0, edges = 0, trias = 0, quads = 0, tetras = 0, hexas = 0, wedges = 0, pyrams = 0, elems = 0, ifaces_1D = 0; long node_id, elem_id, entity_id, property_id, last_entity_id = 0, last_property_id = 0; long node1_id, node2_id, node3_id, node4_id, node5_id, node6_id, node7_id, node8_id; long nd1_id, nd2_id, nd3_id, nd4_id, nd5_id, nd6_id, nd7_id, nd8_id, nd9_id, nd10_id, nd11_id, nd12_id; long bound_cur_id[12], bound_cur_prop[12], bound_ent_id[6], bound_ent_tp[6], bound_ent_prop[6]; long count, load_id, code_id, *ident = NULL, node_array[20], iface_nodes; logic bflag[6], cflag[12], edge_flag[12], bnd_prop, adaptive = NO, singular = NO, inside; int csect, mater, bcond, nic, timef, barriers = 0, randgens = 0; logic obligatory = NO, optional = NO; logic csect_spec = NO, mater_spec = NO, bcond_spec = NO, nic_spec = NO, timef_spec = NO; logic barriers_spec = NO, randgens_spec = NO, topology_spec = NO; logic analysis_rec_processed = NO, component_rec_processed = NO; int records, recs, add_recs, length, num, csect_id, nds, skip_regions = 0, fict_csect = 0; int i, j, mesh_type, elem_degree, renum_type, output_type, entity_type, last_entity_type = 0, lcs_x, lcs_y, cnt, type; double x, y, z, xx, yy, zz, radius, min_elem_size = 0.0, size; point_rec vec[3]; FILE *control_file = NULL, *t3d_out_file = NULL; FILE *oofem_in_file = NULL, *oofem_domain_file = NULL; char control_name[FILE_NAME_SIZE], t3d_out_name[FILE_NAME_SIZE]; char oofem_in_name[FILE_NAME_SIZE], oofem_domain_name[FILE_NAME_SIZE + 7]; char *token = NULL, *string = NULL, err_msg[256], in_err_msg[256], out_err_msg[256], *elem_type = NULL, *line_buf = NULL; list_rec *node_list = NULL, *elem_list = NULL, *entity_list = NULL, *load_id_list = NULL, *code_id_list = NULL, *iface_list = NULL; entity_rec *entity = NULL, *ent = NULL, *master_ent = NULL, *slave_ent = NULL; logic write_rec, domain = NO, help = NO, lcs_spec = NO, tan_nor_spec = NO, read_tan_nor = NO; char *str_ptr = NULL, *str_ptr1 = NULL, *str_ptr2 = NULL, *str_ptr3 = NULL, *str_ptr4 = NULL, ch[3]; char topology[128]; singularity_rec *singularity = NULL; node_rec *fe_node = NULL; list_rec *sing_list = NULL; lcs_rec *lcs = NULL; interface_1D_rec *interface_1D = NULL; int p2h_fc[5] = {1, 3, 4, 5, 6}; /* t3d pyram -> oofem hexa */ int w2h_fc[5] = {1, 2, 3, 4, 6}; /* t3d wedge -> oofem hexa */ int h2h_fc[6] = {1, 2, 3, 4, 5, 6}; /* t3d hexa -> oofem hexa */ /* identity */ int p2h_ed[8] = {1, 2, 3, 4, 5, 6, 7, 8}; /* t3d pyram -> oofem hexa */ /* identity */ int w2h_ed[9] = {1, 2, 4, 9, 10, 12, 5, 6, 8}; /* t3d wedge -> oofem hexa */ int h2h_ed[12] = {1, 2, 3, 4, 9, 10, 11, 12, 5, 6, 7, 8}; /* t3d hexa -> oofem hexa */ if(argc == 2){ if(strcmp(*(argv + 1), "-h") == 0)help = YES; } fprintf(stdout, "\n"); fprintf(stdout, "**************************************\n"); fprintf(stdout, "T3d2oofem: Converter from T3d to Oofem\n"); fprintf(stdout, "Copyright: Daniel Rypl, 2015\n"); fprintf(stdout, "Version: %s\n", VERSION); fprintf(stdout, "**************************************\n"); fprintf(stdout, "\n"); if(argc < 4 || help == YES){ fprintf(stdout, "Usage: t3d2oofem [-h] control_file t3d_output_file oofem_input_file [-din]\n\n"); fprintf(stdout, " -h prints usage and control file keywords\n"); fprintf(stdout, " -din outputs also domain input file (oofem input file without\n"); fprintf(stdout, " certain control records) needed for adaptive analysis\n\n"); if(help == YES){ fprintf(stdout, "\n"); fprintf(stdout, "Control file keywords\n"); fprintf(stdout, "=====================\n"); fprintf(stdout, "\n"); fprintf(stdout, "Model entity specification\n"); fprintf(stdout, "--------------------------\n"); fprintf(stdout, "{Vertex | Curve | Surface | Patch | Shell | Region | Interface} {All [Except int(1+)] | int(1+)}\n"); fprintf(stdout, "\n"); fprintf(stdout, "Property entity specification\n"); fprintf(stdout, "-----------------------------\n"); fprintf(stdout, "Property {All [Except int(1+)] | int(1+)}\n"); fprintf(stdout, "\n"); fprintf(stdout, "1D interface specification\n"); fprintf(stdout, "--------------------------\n"); fprintf(stdout, "Interface1D Vertex int(2) Dir fpn(3)\n"); fprintf(stdout, "Interface1D Curve int(2) {Dir fpn(3) | Tan | Nor fpn(3)}\n"); fprintf(stdout, "Interface1D {Surface | Patch | Shell} int(2) {Dir fpn(3) | Tan (3) | Nor}\n"); fprintf(stdout, "\n"); fprintf(stdout, "Model, property and 1D interface specification cancelation\n"); fprintf(stdout, "----------------------------------------------------------\n"); fprintf(stdout, "Cancel\n"); fprintf(stdout, "\n"); fprintf(stdout, "Feature specification\n"); fprintf(stdout, "---------------------\n"); fprintf(stdout, "{Nodeprop | Elemprop} string\n"); fprintf(stdout, "{Nodetype | Edgetype | Triatype | Quadtype | Tetratype | Hexatype} string\n"); fprintf(stdout, "{Bload | Boundaryload | Bcode | Boundarycode} int\n"); fprintf(stdout, "Lcsprimary {uvw | vwu | wuv | vuw | wvu | uwv} fpn(3)\n"); //fprintf(stdout, "Lcssecondary {Curve | Surface | Patch | shell} int {uvw | vwu | wuv | vuw | wvu | uwv} fpn(3)\n"); fprintf(stdout, "\n"); #ifdef SINGULARITY fprintf(stdout, "Singularity specification\n"); fprintf(stdout, "-------------------------\n"); fprintf(stdout, "Singularnode int fpn (node_id radius)\n"); fprintf(stdout, "Singularpoint fpn(3) fpn (point_coords radius)\n"); fprintf(stdout, "\n"); #endif fprintf(stdout, "Notation\n"); fprintf(stdout, "--------\n"); fprintf(stdout, "{ par1 | par2 | par3 } ... exclusively one from par1, par2 and par3\n"); fprintf(stdout, "[ par ] ... optional parameter\n"); fprintf(stdout, "int ... integer\n"); fprintf(stdout, "fpn ... floating point number\n"); fprintf(stdout, "string ... string\n"); fprintf(stdout, "(n) ... n times\n"); fprintf(stdout, "(n+) ... n or more time\n"); fprintf(stdout, "\n"); return(0); } return(1); } if(strlen(argv[1])>= FILE_NAME_SIZE)error_message("Too long control_file name", LONG_NAME_ERROR); if(strlen(argv[2])>= FILE_NAME_SIZE)error_message("Too long t3d_output_file name", LONG_NAME_ERROR); if(strlen(argv[3])>= FILE_NAME_SIZE)error_message("Too long oofem_input_file name", LONG_NAME_ERROR); strncpy(control_name, argv[1], FILE_NAME_SIZE); strncpy(t3d_out_name, argv[2], FILE_NAME_SIZE); strncpy(oofem_in_name, argv[3], FILE_NAME_SIZE); argc -= 4; argv += 4; while(argc--){ if(strcmp(*argv, "-din") == 0){ domain = YES; argv++; continue; } fprintf(stderr, "Unknown option: %s\n", *argv); } if((control_file = fopen(control_name, "r")) == NULL){ sprintf(err_msg, "File %s opening error", control_name); error_message(err_msg, FILE_OPEN_ERROR); } if((t3d_out_file = fopen(t3d_out_name, "r")) == NULL){ sprintf(err_msg, "File %s opening error", t3d_out_name); error_message(err_msg, FILE_OPEN_ERROR); } if((oofem_in_file = fopen(oofem_in_name, "w")) == NULL){ sprintf(err_msg, "File %s opening error", oofem_in_name); error_message(err_msg, FILE_OPEN_ERROR); } active_in_file = control_file; active_out_file = oofem_in_file; sprintf(in_err_msg, "Unexpected end of control file %s", control_name); sprintf(out_err_msg, "File %s writing error", oofem_in_name); add_recs = 0; #ifdef SINGULARITY /* read provisionally control file to 1) extract region skip map 2) extract number of cross sections 3) check for singularity request */ get_next_relevant_record(in_err_msg); /* OOFEM output file record */ get_next_relevant_record(in_err_msg); /* OOFEM problem description record */ get_next_relevant_record(in_err_msg); /* OOFEM analysis type record */ if(strncasecmp(line_buffer, "adapt", 5) == 0)adaptive = YES; if(adaptive == YES){ analysis_rec_processed = YES; length = (int)strlen(string = line_buffer); for(i = 0; i < length; i++, string++){ if(*string == REMARK)break; if(strncasecmp(string, "nmsteps", 7) == 0){ /* OOFEM metastep count */ string += 7; sscanf(string, "%d", &recs); add_recs += recs; } if(strncasecmp(string, "nmodules", 8) == 0){ /* OOFEM export module count */ string += 8; sscanf(string, "%d", &recs); add_recs += recs; } if(strncasecmp(string, "ninitmodules", 12) == 0){ /* OOFEM init module count */ string += 12; sscanf(string, "%d", &recs); add_recs += recs; } if(strncasecmp(string, "nxfemman", 8) == 0){ /* OOFEM xfem manager count */ string += 8; sscanf(string, "%d", &recs); add_recs += recs; } if(strncasecmp(string, "minelemsize", 11) == 0){ /* OOFEM min elem size */ string += 11; sscanf(string, "%lf", &min_elem_size); } if(strncasecmp(string, "regionskipmap", 13) == 0){ /* OOFEM region skip map */ string += 13; str_ptr1 = string; /* before number of skip regions */ while(*string == ' ' || *string == '\t')string++; sscanf(string, "%d", &skip_regions); while(*string != ' ' && *string != '\t' && *string != '0円' && *string != '\n' && *string != '\r')string++; str_ptr2 = string; /* after number of skip regions */ for(j = 0; j < skip_regions; j++){ while(*string == ' ' || *string == '\t')string++; while(*string != ' ' && *string != '\t' && *string != '0円' && *string != '\n' && *string != '\r')string++; if(*string == '0円' || *string == '\n' || *string == '\r'){ if(j < skip_regions - 1)error_message("Incomplete regionskipmap specification", GENERAL_ERROR); } } str_ptr3 = string++; /* after region skip map */ if(*string != '0円' && *string != '\n' && *string != '\r') str_ptr4 = string; else{ strncpy(ch, str_ptr3, 2); /* make copy of "end" line characters */ str_ptr4 = ch; } } } for(i = 0; i < add_recs; i++)get_next_relevant_record(in_err_msg); /* OOFEM analysis additional records */ get_next_relevant_record(in_err_msg); /* OOFEM domain record */ get_next_relevant_record(in_err_msg); /* OOFEM output manager record */ get_next_relevant_record(in_err_msg); /* OOFEM component size record */ component_rec_processed = YES; length = (int)strlen(string = line_buffer); for(i = 0; i < length; i++, string++){ if(*string == REMARK)break; /* obligatory components */ if(strncasecmp(string, "ncrosssect", 10) == 0){ /* number of cross sections */ if(csect_spec == YES)error_message("Duplicity in component size record", GENERAL_ERROR); string += 10; sscanf(string, "%d", &csect); csect_spec = obligatory = YES; } if(strncasecmp(string, "nmat", 4) == 0){ /* number of materials */ if(mater_spec == YES)error_message("Duplicity in component size record", GENERAL_ERROR); string += 4; sscanf(string, "%d", &mater); mater_spec = obligatory = YES; } if(strncasecmp(string, "nbc", 3) == 0){ /* number of boundary conditions */ if(bcond_spec == YES)error_message("Duplicity in component size record", GENERAL_ERROR); string += 3; sscanf(string, "%d", &bcond); bcond_spec = obligatory = YES; } if(strncasecmp(string, "nic", 3) == 0){ /* number of initial conditions */ if(nic_spec == YES)error_message("Duplicity in component size record", GENERAL_ERROR); string += 3; sscanf(string, "%d", &nic); nic_spec = obligatory = YES; } if(strncasecmp(string, "nltf", 4) == 0){ /* number of load time functions */ if(timef_spec == YES)error_message("Duplicity in component size record", GENERAL_ERROR); string += 4; sscanf(string, "%d", &timef); timef_spec = obligatory = YES; } /* optional components */ if(strncasecmp(string, "nbarrier", 8) == 0){ /* number of nonlocal barriers */ if(barriers_spec == YES)error_message("Duplicity in component size record", GENERAL_ERROR); string += 8; sscanf(string, "%d", &barriers); barriers_spec = optional = YES; } if(strncasecmp(string, "nrandgen", 8) == 0){ /* number of random field generators */ if(randgens_spec == YES)error_message("Duplicity in component size record", GENERAL_ERROR); string += 8; sscanf(string, "%d", &randgens); randgens_spec = optional = YES; } if(strncasecmp(string, "topology", 8) == 0){ /* topology type */ if(topology_spec == YES)error_message("Duplicity in component size record", GENERAL_ERROR); string += 8; sscanf(string, "%s", topology); topology_spec = optional = YES; } } if(obligatory == YES || optional == YES){ if(csect_spec == NO)error_message("Missing number of cross sections ", GENERAL_ERROR); if(mater_spec == NO)error_message("Missing number of materials", GENERAL_ERROR); if(bcond_spec == NO)error_message("Missing number of boundary conditions", GENERAL_ERROR); if(nic_spec == NO)error_message("Missing number of initial contitions", GENERAL_ERROR); if(timef_spec == NO)error_message("Missing number of load time functions", GENERAL_ERROR); } else{ /* process record without keywords (backward compatibility with older ctrl files, ordering of records prescribed) */ if(sscanf(line_buffer, "%d %d %d %d %d", &csect, &mater, &bcond, &nic, &timef) != 5){ sprintf(err_msg, "File %s reading error", control_name); error_message(err_msg, FILE_READ_ERROR); } } if(csect != skip_regions && skip_regions != 0) error_message("Inconsistency between region skip map and number of cross sections", GENERAL_ERROR); for(i = 0; i < csect; i++) get_next_relevant_record(in_err_msg); /* OOFEM cross section record */ for(i = 0; i < mater; i++) get_next_relevant_record(in_err_msg); /* OOFEM material record */ for(i = 0; i < barriers; i++) get_next_relevant_record(in_err_msg); /* OOFEM nonlocal barrier record */ for(i = 0; i < randgens; i++) get_next_relevant_record(in_err_msg); /* OOFEM random field generator record */ for(i = 0; i < bcond; i++) get_next_relevant_record(in_err_msg); /* OOFEM boundary condition record */ for(i = 0; i < nic; i++) get_next_relevant_record(in_err_msg); /* OOFEM initial condition record */ for(i = 0; i < timef; i++) get_next_relevant_record(in_err_msg); /* OOFEM time function record */ /* check if singularity is requested */ while((token = get_first_token(NULL)) != NULL){ key = get_token_key(token, keyword, KEY_NUM); if(key == SINGULARNODE || key == SINGULARPOINT){ singular = YES; fict_csect = csect; break; } } } rewind(active_in_file = control_file); #endif read_write_until_next_relevant_record(in_err_msg, out_err_msg); /* OOFEM output file record */ read_write_until_next_relevant_record(in_err_msg, out_err_msg); /* OOFEM problem description record */ if(singular == NO){ read_write_until_next_relevant_record(in_err_msg, out_err_msg); /* OOFEM analysis type record */ if(analysis_rec_processed == NO){ analysis_rec_processed = YES; /* sum number of additional records if not processed above */ length = (int)strlen(string = line_buffer); for(i = 0; i < length; i++, string++){ if(*string == REMARK)break; if(strncasecmp(string, "nmsteps", 7) == 0){ /* OOFEM metastep count */ string += 7; sscanf(string, "%d", &recs); add_recs += recs; } if(strncasecmp(string, "nmodules", 8) == 0){ /* OOFEM export module count */ string += 8; sscanf(string, "%d", &recs); add_recs += recs; } if(strncasecmp(string, "ninitmodules", 12) == 0){ /* OOFEM init module count */ string += 12; sscanf(string, "%d", &recs); add_recs += recs; } if(strncasecmp(string, "nxfemman", 8) == 0){ /* OOFEM xfem manager count */ string += 8; sscanf(string, "%d", &recs); add_recs += recs; } } } } else{ read_write_unrelevant_records(in_err_msg, out_err_msg); /* OOFEM analysis record */ if(skip_regions == 0){ /* add region skip map to analysis record */ length = (int)strlen(line_buffer); line_buffer[length - 1] = '0円'; /* override \n character */ if(fprintf(oofem_in_file, "%s regionskipmap %d", line_buffer, csect + fict_csect) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM analysis record */ for(j = 0; j < csect; j++){ if(fprintf(oofem_in_file, " 0") < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM analysis record (existing regions) */ } for(j = 0; j < csect; j++){ if(fprintf(oofem_in_file, " 1") < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM analysis record (fictitious regions) */ } if(fprintf(oofem_in_file, "\n") < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM analysis record */ } else{ /* modify region skip map in analysis record */ *str_ptr1 = *str_ptr3 = '0円'; if(fprintf(oofem_in_file, "%s %d%s", line_buffer, csect + fict_csect, str_ptr2) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM analysis record (up to end of region skip map with new array size) */ for(j = 0; j < csect; j++){ if(fprintf(oofem_in_file, " 1") < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM analysis record (rest of map) */ } if(fprintf(oofem_in_file, " %s", str_ptr4) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM analysis record (rest after map) */ } } for(i = 0; i < add_recs; i++) read_write_until_next_relevant_record(in_err_msg, out_err_msg); /* OOFEM analysis additional records */ read_write_until_next_relevant_record(in_err_msg, out_err_msg); /* OOFEM domain record */ read_write_until_next_relevant_record(in_err_msg, out_err_msg); /* OOFEM output manager record */ read_write_unrelevant_records(in_err_msg, out_err_msg); if(component_rec_processed == NO){ component_rec_processed = YES; /* process component size records if not done above */ length = (int)strlen(string = line_buffer); for(i = 0; i < length; i++, string++){ if(*string == REMARK)break; /* obligatory components */ if(strncasecmp(string, "ncrosssect", 10) == 0){ /* number of cross sections */ if(csect_spec == YES)error_message("Duplicity in component size record", GENERAL_ERROR); string += 10; sscanf(string, "%d", &csect); csect_spec = obligatory = YES; } if(strncasecmp(string, "nmat", 4) == 0){ /* number of materials */ if(mater_spec == YES)error_message("Duplicity in component size record", GENERAL_ERROR); string += 4; sscanf(string, "%d", &mater); mater_spec = obligatory = YES; } if(strncasecmp(string, "nbc", 3) == 0){ /* number of boundary conditions */ if(bcond_spec == YES)error_message("Duplicity in component size record", GENERAL_ERROR); string += 3; sscanf(string, "%d", &bcond); bcond_spec = obligatory = YES; } if(strncasecmp(string, "nic", 3) == 0){ /* number of initial conditions */ if(nic_spec == YES)error_message("Duplicity in component size record", GENERAL_ERROR); string += 3; sscanf(string, "%d", &nic); nic_spec = obligatory = YES; } if(strncasecmp(string, "nltf", 4) == 0){ /* number of load time functions */ if(timef_spec == YES)error_message("Duplicity in component size record", GENERAL_ERROR); string += 4; sscanf(string, "%d", &timef); timef_spec = obligatory = YES; } /* optional components */ if(strncasecmp(string, "nbarrier", 8) == 0){ /* number of nonlocal barriers */ if(barriers_spec == YES)error_message("Duplicity in component size record", GENERAL_ERROR); string += 8; sscanf(string, "%d", &barriers); barriers_spec = optional = YES; } if(strncasecmp(string, "nrandgen", 8) == 0){ /* number of random field generators */ if(randgens_spec == YES)error_message("Duplicity in component size record", GENERAL_ERROR); string += 8; sscanf(string, "%d", &randgens); randgens_spec = optional = YES; } if(strncasecmp(string, "topology", 8) == 0){ /* topology type */ if(topology_spec == YES)error_message("Duplicity in component size record", GENERAL_ERROR); string += 8; sscanf(string, "%s", topology); topology_spec = optional = YES; } } if(obligatory == YES || optional == YES){ if(csect_spec == NO)error_message("Missing number of cross sections ", GENERAL_ERROR); if(mater_spec == NO)error_message("Missing number of materials", GENERAL_ERROR); if(bcond_spec == NO)error_message("Missing number of boundary conditions", GENERAL_ERROR); if(nic_spec == NO)error_message("Missing number of initial contitions", GENERAL_ERROR); if(timef_spec == NO)error_message("Missing number of load time functions", GENERAL_ERROR); } else{ /* process record without keywords (backward compatibility with older ctrl files, ordering of records prescribed) */ if(sscanf(line_buffer, "%d %d %d %d %d", &csect, &mater, &bcond, &nic, &timef) != 5){ sprintf(err_msg, "File %s reading error", control_name); error_message(err_msg, FILE_READ_ERROR); } } } /* skip cross section, material, barrier, random field generator, boundary condition, initial condition and load time function records */ records = csect + mater + barriers + randgens + bcond + nic + timef; while(records--){ get_next_relevant_record(in_err_msg); } while((token = get_first_token(NULL)) != NULL){ key = get_token_key(token, keyword, KEY_NUM); switch(key){ case CANCEL: if(entity_select == YES){ if(vertex_select == YES)deselect_entity_list(vertex_list); if(curve_select == YES)deselect_entity_list(curve_list); if(surface_select == YES)deselect_entity_list(surface_list); if(patch_select == YES)deselect_entity_list(patch_list); if(shell_select == YES)deselect_entity_list(shell_list); if(region_select == YES)deselect_entity_list(region_list); if(interface_select == YES)deselect_entity_list(interface_list); if(multi_select == YES){ if(vertex_select == YES)deselect_entities_list(vertices_list); if(curve_select == YES)deselect_entities_list(curves_list); if(surface_select == YES)deselect_entities_list(surfaces_list); if(patch_select == YES)deselect_entities_list(patches_list); if(shell_select == YES)deselect_entities_list(shells_list); if(region_select == YES)deselect_entities_list(regions_list); if(interface_select == YES)deselect_entities_list(interfaces_list); } vertex_select = curve_select = surface_select = patch_select = shell_select = region_select = interface_select = NO; } if(property_select == YES)deselect_entity_list(property_list); if(interface_1D_select == YES)deselect_interface_1D_list(); multi_select = entity_select = property_select = node_elem_select = interface_1D_select = NO; break; case VERTEX: case CURVE: case SURFACE: case PATCH: case SHELL: case REGION: case INTERFACE: if(node_elem_select == YES){ if(entity_select == YES){ if(vertex_select == YES)deselect_entity_list(vertex_list); if(curve_select == YES)deselect_entity_list(curve_list); if(surface_select == YES)deselect_entity_list(surface_list); if(patch_select == YES)deselect_entity_list(patch_list); if(shell_select == YES)deselect_entity_list(shell_list); if(region_select == YES)deselect_entity_list(region_list); if(interface_select == YES)deselect_entity_list(interface_list); if(multi_select == YES){ if(vertex_select == YES)deselect_entities_list(vertices_list); if(curve_select == YES)deselect_entities_list(curves_list); if(surface_select == YES)deselect_entities_list(surfaces_list); if(patch_select == YES)deselect_entities_list(patches_list); if(shell_select == YES)deselect_entities_list(shells_list); if(region_select == YES)deselect_entities_list(regions_list); if(interface_select == YES)deselect_entities_list(interfaces_list); } vertex_select = curve_select = surface_select = patch_select = shell_select = region_select = interface_select = NO; } if(property_select == YES)deselect_entity_list(property_list); if(interface_1D_select == YES)deselect_interface_1D_list(); multi_select = entity_select = property_select = node_elem_select = interface_1D_select = NO; } else{ if(property_select == YES){ sprintf(err_msg, "Keyword %s not expected together with any entity keyword", keyword[PROPERTY]); error_message(err_msg, GENERAL_ERROR); } if(interface_1D_select == YES){ sprintf(err_msg, "Keyword %s not expected together with any entity keyword", keyword[INTERFACE1D]); error_message(err_msg, GENERAL_ERROR); } } entity_select = YES; break; case PROPERTY: if(node_elem_select == YES){ if(entity_select == YES){ if(vertex_select == YES)deselect_entity_list(vertex_list); if(curve_select == YES)deselect_entity_list(curve_list); if(surface_select == YES)deselect_entity_list(surface_list); if(patch_select == YES)deselect_entity_list(patch_list); if(shell_select == YES)deselect_entity_list(shell_list); if(region_select == YES)deselect_entity_list(region_list); if(interface_select == YES)deselect_entity_list(interface_list); if(multi_select == YES){ if(vertex_select == YES)deselect_entities_list(vertices_list); if(curve_select == YES)deselect_entities_list(curves_list); if(surface_select == YES)deselect_entities_list(surfaces_list); if(patch_select == YES)deselect_entities_list(patches_list); if(shell_select == YES)deselect_entities_list(shells_list); if(region_select == YES)deselect_entities_list(regions_list); if(interface_select == YES)deselect_entities_list(interfaces_list); } vertex_select = curve_select = surface_select = patch_select = shell_select = region_select = interface_select = NO; } if(property_select == YES)deselect_entity_list(property_list); if(interface_1D_select == YES)deselect_interface_1D_list(); multi_select = entity_select = property_select = node_elem_select = interface_1D_select = NO; } else{ if(entity_select == YES){ sprintf(err_msg, "Keyword %s not expected together with any entity keyword", keyword[PROPERTY]); error_message(err_msg, GENERAL_ERROR); } if(interface_1D_select == YES){ sprintf(err_msg, "Keyword %s not expected together with %s keyword", keyword[INTERFACE1D], keyword[PROPERTY]); error_message(err_msg, GENERAL_ERROR); } } break; case NODEPROP: case ELEMPROP: if(entity_select == NO && property_select == NO && interface_1D_select == NO) error_message("Entity or property specification missing", GENERAL_ERROR); if((token = get_next_token(NULL)) == NULL) error_message("Missing node or element property", GENERAL_ERROR); /* do not use line_buffer (memory overlapping may occur) */ *temp_buffer = '0円'; while(token != NULL){ /* each token must be preceeded by space */ strcat(temp_buffer, " "); strcat(temp_buffer, token); token = get_next_token(NULL); } string = store_string(temp_buffer); string_list = add_item_to_list_head(string_list, (void *)string); node_elem_select = YES; break; case NODETYPE: if(entity_select == NO) error_message("Entity specification missing", GENERAL_ERROR); if((token = get_next_token(NULL)) == NULL) error_message("Missing node type", GENERAL_ERROR); string = store_string(token); string_list = add_item_to_list_head(string_list, (void *)string); if((token = get_next_token(NULL)) != NULL) error_message("Redundant node type specification detected", GENERAL_ERROR); node_elem_select = YES; break; case ELEMTYPE: /* for compatibility reasons */ case EDGETYPE: case TRIATYPE: case QUADTYPE: case TETRATYPE: case HEXATYPE: if(entity_select == NO) error_message("Entity specification missing", GENERAL_ERROR); if((token = get_next_token(NULL)) == NULL) error_message("Missing element type", GENERAL_ERROR); string = store_string(token); string_list = add_item_to_list_head(string_list, (void *)string); if((token = get_next_token(NULL)) != NULL) error_message("Redundant element type specification detected", GENERAL_ERROR); node_elem_select = YES; break; case BLOAD: case BOUNDARYLOAD: case BCODE: case BOUNDARYCODE: case LCSPRIMARY: // case LCSSECONDARY: case SINGULARNODE: case SINGULARPOINT: /* singular node should be processed without entity specification; relevant entities should be identified from elements incident to that node; however this would require either duplicated processing of t3d output file or storing all elements (including classification and boundary information); therefore current version relies on entity specification instead; this has the advantage that reentrant corner on a particular entity does not implicitly result in singularity on other entities sharing that corner */ if(entity_select == NO) error_message("Entity specification missing", GENERAL_ERROR); node_elem_select = YES; break; case INTERFACE1D: if(entity_select == YES || property_select == YES){ if(entity_select == YES){ if(vertex_select == YES)deselect_entity_list(vertex_list); if(curve_select == YES)deselect_entity_list(curve_list); if(surface_select == YES)deselect_entity_list(surface_list); if(patch_select == YES)deselect_entity_list(patch_list); if(shell_select == YES)deselect_entity_list(shell_list); if(region_select == YES)deselect_entity_list(region_list); if(interface_select == YES)deselect_entity_list(interface_list); if(multi_select == YES){ if(vertex_select == YES)deselect_entities_list(vertices_list); if(curve_select == YES)deselect_entities_list(curves_list); if(surface_select == YES)deselect_entities_list(surfaces_list); if(patch_select == YES)deselect_entities_list(patches_list); if(shell_select == YES)deselect_entities_list(shells_list); if(region_select == YES)deselect_entities_list(regions_list); if(interface_select == YES)deselect_entities_list(interfaces_list); } vertex_select = curve_select = surface_select = patch_select = shell_select = region_select = interface_select = NO; } if(property_select == YES)deselect_entity_list(property_list); multi_select = entity_select = property_select = node_elem_select = NO; } interface_1D_select = YES; break; /* to ensure compatibility with t3d2poofem */ case ELEMWEIGHT: case EDGEWEIGHT: case TRIAWEIGHT: case QUADWEIGHT: case TETRAWEIGHT: case PYRAMWEIGHT: case WEDGEWEIGHT: case HEXAWEIGHT: case WIDTH: case PARTITION: case MASTER: node_elem_select = YES; break; default: sprintf(err_msg, "Unexpected or invalid keyword \"%s\" encountered", token); error_message(err_msg, GENERAL_ERROR); break; } switch(key){ case CANCEL: break; case VERTEX: process_entity_list(&vertex_list, &vertices_list, keyword[VERTEX], VERTEX_ENTITY); vertex_select = YES; break; case CURVE: process_entity_list(&curve_list, &curves_list, keyword[CURVE], CURVE_ENTITY); curve_select = YES; break; case SURFACE: process_entity_list(&surface_list, &surfaces_list, keyword[SURFACE], SURFACE_ENTITY); surface_select = YES; break; case PATCH: process_entity_list(&patch_list, &patches_list, keyword[PATCH], PATCH_ENTITY); patch_select = YES; break; case SHELL: process_entity_list(&shell_list, &shells_list, keyword[SHELL], SHELL_ENTITY); shell_select = YES; break; case REGION: process_entity_list(®ion_list, ®ions_list, keyword[REGION], REGION_ENTITY); region_select = YES; break; case INTERFACE: process_entity_list(&interface_list, &interfaces_list, keyword[INTERFACE], INTERFACE_ENTITY); interface_select = YES; break; case PROPERTY: process_entity_list(&property_list, NULL, keyword[PROPERTY], PROPERTY_ENTITY); property_select = YES; break; case NODEPROP: apply_node_properties(string); break; case ELEMPROP: apply_elem_properties(string); break; case NODETYPE: apply_node_type(string); break; case ELEMTYPE: case EDGETYPE: case TRIATYPE: case QUADTYPE: case TETRATYPE: case HEXATYPE: apply_elem_type(string); break; case BLOAD: case BOUNDARYLOAD: load_id = 0; while((token = get_next_token(NULL)) != NULL){ if((load_id = get_int_from_token(token)) <= 0){ sprintf(err_msg, "Invalid boundary load id (%ld)", load_id); error_message(err_msg, GENERAL_ERROR); } if((ident = get_id(id_list, load_id)) == NULL){ ident = create_id(load_id); id_list = add_item_to_list_head(id_list, (void *)ident); } apply_elem_bload(ident); } if(load_id == 0){ sprintf(err_msg, "Missing boundary load id"); error_message(err_msg, GENERAL_ERROR); } break; case BCODE: case BOUNDARYCODE: code_id = 0; while((token = get_next_token(NULL)) != NULL){ if((code_id = get_int_from_token(token)) <= 0){ sprintf(err_msg, "Invalid boundary code id (%ld)", code_id); error_message(err_msg, GENERAL_ERROR); } if((ident = get_id(id_list, code_id)) == NULL){ ident = create_id(code_id); id_list = add_item_to_list_head(id_list, (void *)ident); } apply_elem_bcode(ident); } if(code_id == 0){ sprintf(err_msg, "Missing boundary code id"); error_message(err_msg, GENERAL_ERROR); } break; #if 0 case LCSSECONDARY: if((token = get_next_token(NULL)) == NULL) error_message("Missing entity type", GENERAL_ERROR); last_key = key; key = get_token_key(token, keyword, KEY_NUM); switch(key){ case CURVE: case SURFACE: case PATCH: case SHELL: break; case VERTEX: case REGION: case INTERFACE: error_message("Unexpected entity type", GENERAL_ERROR); break; default: error_message("Unknown entity type", GENERAL_ERROR); break; } key = last_key; if((token = get_next_token(NULL)) == NULL) error_message("Missing entity id", GENERAL_ERROR); if((entity_id = get_int_from_token(token)) <= 0){ sprintf(err_msg, "Invalid entity id (%ld)", entity_id); error_message(err_msg, GENERAL_ERROR); } fprintf(stderr, "Warning: Secondary lcs not supported in this version\n"); /* support requires that output of secondary tangents (at vertices with respect to incident curves) and normals (at vertices and curves with respect to incident surfaces) is available */ break; /* when supported, remove break */ /* do not use break ! */ #endif case LCSPRIMARY: if((token = get_next_token(NULL)) == NULL) error_message("Missing lcs type", GENERAL_ERROR); last_key = key; key = get_token_key(token, keyword, KEY_NUM); switch(key){ case UVW: lcs_x = 0; lcs_y = 1; break; case VWU: lcs_x = 1; lcs_y = 2; break; case WUV: lcs_x = 2; lcs_y = 0; break; case VUW: lcs_x = 1; lcs_y = 0; break; case WVU: lcs_x = 2; lcs_y = 1; break; case UWV: lcs_x = 0; lcs_y = 2; break; default: error_message("Unknown lcs type", GENERAL_ERROR); break; } key = last_key; if((token = get_next_token(NULL)) == NULL) error_message("Missing ref vector x component", GENERAL_ERROR); x = get_fpn_from_token(token); if((token = get_next_token(NULL)) == NULL) error_message("Missing ref vector y component", GENERAL_ERROR); y = get_fpn_from_token(token); if((token = get_next_token(NULL)) == NULL) error_message("Missing ref vector z component", GENERAL_ERROR); z = get_fpn_from_token(token); size = sqrt(x * x + y * y + z * z); if(size < 1.0e-10)error_message("Zero ref vector", GENERAL_ERROR); /* I cannot get pointer to appropriate entity as it may not exist yet */ #if 0 if(key == LCSSECONDARY) lcs = create_lcs(entity_type, entity_id, lcs_x, lcs_y, x, y, z); else #endif lcs = create_lcs(0, 0, lcs_x, lcs_y, x, y, z); lcs_list = add_item_to_list_head(lcs_list, (void *)lcs); apply_lcs(lcs); lcs_spec = YES; break; case SINGULARNODE: if((token = get_next_token(NULL)) == NULL) error_message("Missing singular node id", GENERAL_ERROR); if((node_id = get_int_from_token(token)) <= 0){ sprintf(err_msg, "Invalid singular node id (%ld)", node_id); error_message(err_msg, GENERAL_ERROR); } if((token = get_next_token(NULL)) == NULL) error_message("Missing singular node radius", GENERAL_ERROR); radius = get_fpn_from_token(token); if(radius != 0.0){ if(radius < 0.0){ /* nagative radius is treated as multiplier of min elem size */ if(min_elem_size == 0.0) error_message("Negative radius cannot be used if min element size is not specified", GENERAL_ERROR); radius = -radius * min_elem_size; } #ifdef SINGULARITY singularity = create_singularity(node_id, 0.0, 0.0, 0.0, radius); singularity_list = add_item_to_list_head(singularity_list, (void *)singularity); apply_singularity(singularity); #else fprintf(stderr, "Warning: Singularities not supported in this verison\n"); #endif } break; case SINGULARPOINT: if((token = get_next_token(NULL)) == NULL) error_message("Missing singular point x coordinate", GENERAL_ERROR); x = get_fpn_from_token(token); if((token = get_next_token(NULL)) == NULL) error_message("Missing singular point y coordinate", GENERAL_ERROR); y = get_fpn_from_token(token); if((token = get_next_token(NULL)) == NULL) error_message("Missing singular point z coordinate", GENERAL_ERROR); z = get_fpn_from_token(token); if((token = get_next_token(NULL)) == NULL) error_message("Missing singular node radius", GENERAL_ERROR); radius = get_fpn_from_token(token); if(radius != 0.0){ if(radius < 0.0){ /* nagative radius is treated as multiplier of min elem size */ if(min_elem_size == 0.0) error_message("Negative radius cannot be used if min element size is not specified", GENERAL_ERROR); radius = -radius * min_elem_size; } #ifdef SINGULARITY singularity = create_singularity(0, x, y, z, radius); singularity_list = add_item_to_list_head(singularity_list, (void *)singularity); apply_singularity(singularity); #endif } break; case INTERFACE1D: if((token = get_next_token(NULL)) == NULL) error_message("Missing entity type", GENERAL_ERROR); last_key = key; key = get_token_key(token, keyword, KEY_NUM); switch(key){ case VERTEX: entity_list = vertex_list; entity_type = VERTEX_ENTITY; break; case CURVE: entity_list = curve_list; entity_type = CURVE_ENTITY; break; case SURFACE: entity_list = surface_list; entity_type = SURFACE_ENTITY; break; case PATCH: entity_list = patch_list; entity_type = PATCH_ENTITY; break; case SHELL: entity_list = shell_list; entity_type = SHELL_ENTITY; break; break; case REGION: case INTERFACE: error_message("Unexpected entity type", GENERAL_ERROR); break; default: error_message("Unknown entity type", GENERAL_ERROR); break; } key = last_key; if((token = get_next_token(NULL)) == NULL) error_message("Missing master entity id", GENERAL_ERROR); if((entity_id = get_int_from_token(token)) <= 0){ sprintf(err_msg, "Invalid entity id (%ld)", entity_id); error_message(err_msg, GENERAL_ERROR); } master_ent = get_entity_id(entity_list, entity_id); if(master_ent == NULL)master_ent = create_missing_entity_id(entity_id, entity_type); if((token = get_next_token(NULL)) == NULL) error_message("Missing slave entity id", GENERAL_ERROR); if((entity_id = get_int_from_token(token)) <= 0){ sprintf(err_msg, "Invalid entity id (%ld)", entity_id); error_message(err_msg, GENERAL_ERROR); } slave_ent = get_entity_id(entity_list, entity_id); if(slave_ent == NULL)slave_ent = create_missing_entity_id(entity_id, entity_type); /* note: if master_ent was created as missing then entity_list is not pointing to the head of entity list any more (it is pointing to the second entry); this may cause problem if entity_id of the slave is same as master_ent id because in such a case slave entity is not found (first entry is skipped) and missing slave_ent is created rather than reporting an error; therefore id of master_ent ans slave_ent must be checked against each other explicitly */ if(slave_ent -> id == master_ent -> id)error_message("Master must be different from slave", GENERAL_ERROR); if((token = get_next_token(NULL)) == NULL) error_message("Missing direction specification", GENERAL_ERROR); last_key = key; key = get_token_key(token, keyword, KEY_NUM); switch(key){ case DIR: type = 0; if((token = get_next_token(NULL)) == NULL) error_message("Missing dir vector x component", GENERAL_ERROR); x = get_fpn_from_token(token); if((token = get_next_token(NULL)) == NULL) error_message("Missing dir vector y component", GENERAL_ERROR); y = get_fpn_from_token(token); if((token = get_next_token(NULL)) == NULL) error_message("Missing dir vector z component", GENERAL_ERROR); z = get_fpn_from_token(token); break; case TAN: if(entity_type == VERTEX_ENTITY) error_message("Keyword TAN not expected for vertices", GENERAL_ERROR); tan_nor_spec = YES; if(entity_type == CURVE_ENTITY) type = 1; else{ type = 2; if((token = get_next_token(NULL)) == NULL) error_message("Missing tan vector x component", GENERAL_ERROR); x = get_fpn_from_token(token); if((token = get_next_token(NULL)) == NULL) error_message("Missing tan vector y component", GENERAL_ERROR); y = get_fpn_from_token(token); if((token = get_next_token(NULL)) == NULL) error_message("Missing tan vector z component", GENERAL_ERROR); z = get_fpn_from_token(token); } break; case NOR: if(entity_type == VERTEX_ENTITY) error_message("Keyword NOR not expected for vertices", GENERAL_ERROR); tan_nor_spec = YES; if(entity_type != CURVE_ENTITY) type = 3; else{ type = 4; if((token = get_next_token(NULL)) == NULL) error_message("Missing nor vector x component", GENERAL_ERROR); x = get_fpn_from_token(token); if((token = get_next_token(NULL)) == NULL) error_message("Missing nor vector y component", GENERAL_ERROR); y = get_fpn_from_token(token); if((token = get_next_token(NULL)) == NULL) error_message("Missing nor vector z component", GENERAL_ERROR); z = get_fpn_from_token(token); } break; default: error_message("Unexpected keyword", GENERAL_ERROR); break; } key = last_key; interface_1D = create_interface_1D(master_ent, slave_ent, type, x, y, z); interface_1D_list = add_item_to_list_head(interface_1D_list, (void *)interface_1D); interface_1D -> selected = YES; master_ent -> interface_1D = slave_ent -> interface_1D = YES; break; /* to ensure compatibility with t3d2poofem */ case ELEMWEIGHT: case EDGEWEIGHT: case TRIAWEIGHT: case QUADWEIGHT: case TETRAWEIGHT: case PYRAMWEIGHT: case WEDGEWEIGHT: case HEXAWEIGHT: case WIDTH: case PARTITION: case MASTER: break; default: sprintf(err_msg, "Unexpected or invalid keyword \"%s\" encountered", token); error_message(err_msg, GENERAL_ERROR); break; } } if(node_elem_select == NO){ if(entity_select == YES || property_select == YES || interface_1D_select == YES) error_message("Node or elem properties missing", GENERAL_ERROR); } if(entity_select == YES){ if(vertex_select == YES)deselect_entity_list(vertex_list); if(curve_select == YES)deselect_entity_list(curve_list); if(surface_select == YES)deselect_entity_list(surface_list); if(patch_select == YES)deselect_entity_list(patch_list); if(shell_select == YES)deselect_entity_list(shell_list); if(region_select == YES)deselect_entity_list(region_list); if(interface_select == YES)deselect_entity_list(interface_list); if(multi_select == YES){ if(vertex_select == YES)deselect_entities_list(vertices_list); if(curve_select == YES)deselect_entities_list(curves_list); if(surface_select == YES)deselect_entities_list(surfaces_list); if(patch_select == YES)deselect_entities_list(patches_list); if(shell_select == YES)deselect_entities_list(shells_list); if(region_select == YES)deselect_entities_list(regions_list); if(interface_select == YES)deselect_entities_list(interfaces_list); } vertex_select = curve_select = surface_select = patch_select = shell_select = region_select = interface_select = NO; } if(property_select == YES)deselect_entity_list(property_list); if(interface_1D_select == YES)deselect_interface_1D_list(); multi_select = entity_select = property_select = node_elem_select = interface_1D_select = NO; /* it is better to reverse the list in the instance of use (not all entities may be actually used) */ /* #ifdef DEFAULT_FIRST reverse_node_elem_entity_list(vertex_list); reverse_node_elem_entity_list(curve_list); reverse_node_elem_entity_list(surface_list); reverse_node_elem_entity_list(patch_list); reverse_node_elem_entity_list(shell_list); reverse_node_elem_entity_list(region_list); reverse_node_elem_entity_list(interface_list); #endif */ reverse_node_elem_entity_list(property_list); active_in_file = t3d_out_file; sprintf(in_err_msg, "File %s reading error", t3d_out_name); get_next_relevant_record(in_err_msg); if(sscanf(line_buffer, "%d %d %d %d", &mesh_type, &elem_degree, &renum_type, &output_type) != 4) error_message(in_err_msg, FILE_READ_ERROR); if((output_type & 8) == 0) error_message("Invalid t3d -p option (specification 8 or 512 missing)", GENERAL_ERROR); get_next_relevant_record(in_err_msg); switch(mesh_type){ case TRI_TETRA: if(sscanf(line_buffer, "%ld %ld %ld %ld", &nodes, &edges, &trias, &tetras) != 4) error_message(in_err_msg, FILE_READ_ERROR); elems = edges + trias + tetras; break; case QUAD_HEXA: if(sscanf(line_buffer, "%ld %ld %ld %ld", &nodes, &edges, &quads, &hexas) != 4) error_message(in_err_msg, FILE_READ_ERROR); elems = edges + quads + hexas; break; case TRI_TETRA + QUAD_HEXA: if(sscanf(line_buffer, "%ld %ld %ld %ld %ld %ld %ld %ld", &nodes, &edges, &trias, &quads, &tetras, &pyrams, &wedges, &hexas) != 8) error_message(in_err_msg, FILE_READ_ERROR); elems = edges + trias + quads + tetras + pyrams + wedges + hexas; break; default: error_message("Unknown element type", GENERAL_ERROR); break; } if((output_type & 512) == 0){ if(tetras != 0 || pyrams != 0 || wedges != 0 || hexas != 0){ fprintf(stderr, "\n"); fprintf(stderr, "Warning: Edgeload (if any) applied to 3D elements is ignored\n"); fprintf(stderr, " unless t3d was executed with -p option including 512\n\n"); } } if((output_type & 2) == 0 || (output_type & 4) == 0){ if(lcs_spec == YES){ //error_message("Local coordinate system request cannot be processed\nunless t3d was executed with -p option including 2 and 4", GENERAL_ERROR); fprintf(stderr, "\n"); fprintf(stderr, "Warning: Local coordinate system specification is ignored\n"); fprintf(stderr, " unless t3d was executed with -p option including 2 and 4\n\n"); lcs_spec = NO; } if(tan_nor_spec == YES){ error_message("Interface_1D with tangent or normal direction cannot be processed\nunless t3d was executed with -p option including 2 and 4", GENERAL_ERROR); } } if(tan_nor_spec == YES){ if(renum_type != 0) error_message("Interface_1D with tangent or normal direction cannot be processed on renumbered mesh", GENERAL_ERROR); } switch(elem_degree){ case LINEAR: case QUADRATIC: break; default: error_message("Unsupported element degree", GENERAL_ERROR); break; } if(nodes == 0) error_message("Not enough nodes found", GENERAL_ERROR); if(elem_degree == LINEAR){ if((con_node1 = (long *)calloc(nodes, sizeof(long))) == NULL) error_message("Memory allocation error", MEMORY_ERROR); if((con_node2 = (long *)calloc(nodes, sizeof(long))) == NULL) error_message("Memory allocation error", MEMORY_ERROR); } else{ if((node_flag = (long *)calloc(nodes, sizeof(long))) == NULL) error_message("Memory allocation error", MEMORY_ERROR); } #ifndef SINGULARITY if(singular == YES){ singularity = NO; fprintf(stderr, "\n"); fprintf(stderr, "Warning: Singularity not supported.\n\n"); } #endif if(singular == YES){ if((fe_nodes = (node_rec *)calloc(nodes, sizeof(node_rec))) == NULL) error_message("Memory allocation error", MEMORY_ERROR); } /* caution: nelem does not include ifaces_1D !!! */ if(fprintf(oofem_in_file, "ndofman %ld nelem %ld ncrosssect %d nmat %d nbc %d nic %d nltf %d", nodes, elems, csect + fict_csect, mater, bcond, nic, timef) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM component size record */ if(barriers != 0){ if(fprintf(oofem_in_file, "nbarrier %d", barriers) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM component size record */ } if(randgens != 0){ if(fprintf(oofem_in_file, "nrandgen %d", randgens) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM component size record */ } if(topology_spec == YES){ if(fprintf(oofem_in_file, "topology %s", topology) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM component size record */ } if(fprintf(oofem_in_file, "\n") < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM component size record */ last_entity_type = 0; last_entity_id = 0; last_property_id = 0; for(i = 0; i < nodes; i++){ get_next_relevant_record(in_err_msg); if(sscanf(line_buffer, "%ld %lf %lf %lf %d %ld %ld", &node_id, &x, &y, &z, &entity_type, &entity_id, &property_id) != 7) error_message(in_err_msg, FILE_READ_ERROR); cnt = 0; line_buf = line_buffer; while(cnt++ != 7){ while(*line_buf == ' ')line_buf++; /* skip leading spaces */ while(*line_buf != ' ' && *line_buf != '\n' && *line_buf != '0円')line_buf++; /* skip item */ } /* continuous numbering of nodes from 1 to nodes is required for proper handling of edge_flag (for bload and bcode) and for handling singularity */ if(node_id <= 0 || node_id> nodes) error_message("Invalid node numbering", GENERAL_ERROR); switch(entity_type){ case VERTEX_ENTITY: entity_list = vertex_list; if(elem_degree == LINEAR)con_node1[node_id - 1] = con_node2[node_id - 1] = -entity_id; break; case CURVE_ENTITY: entity_list = curve_list; break; case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; case REGION_ENTITY: entity_list = region_list; break; case INTERFACE_ENTITY: error_message("Unexpected situation", GENERAL_ERROR); break; default: error_message("Unknown entity type", GENERAL_ERROR); break; } if(last_entity_type != entity_type || last_entity_id != entity_id){ entity = get_entity_id(entity_list, entity_id); if(entity == NULL)entity = create_missing_entity_id(entity_id, entity_type); if(entity -> selected == NO){ #ifdef DEFAULT_FIRST entity -> node_prop_list = reverse_list(entity -> node_prop_list); if(entity_type != VERTEX_ENTITY) entity -> elem_prop_list = reverse_list(entity -> elem_prop_list); #endif process_entity(entity, entity_type); } last_entity_type = entity_type; last_entity_id = entity_id; entity -> on_output = YES; read_tan_nor = NO; if(entity -> lcs != NULL && lcs_spec == YES){ if(entity -> lcs -> entity_id == 0)read_tan_nor = YES; } /* check whether entity is on TAN or NOR interface_1D, nodes of opposite part of which has been already read; it is assumed that nodes are in native order and that renumbering was not applied; this implies that once the variable nodes on entity corresponding to the opposite part is nonzero, the opposite part has been already read; memory is allocated only if tangent or normal direction (interface_1D -> type != 0) is required */ iface_nodes = 0; interface_1D = NULL; if(entity -> interface_1D == YES){ iface_list = interface_1D_list; while(iface_list != NULL){ interface_1D = (interface_1D_rec *)(iface_list -> item); iface_list = iface_list -> next; if(interface_1D -> master == entity || interface_1D -> slave == entity){ if(interface_1D -> master == entity) iface_nodes = interface_1D -> slave -> nodes; else iface_nodes = interface_1D -> master -> nodes; if(iface_nodes != 0){ /* opposite part of interface_1D already read */ ifaces_1D += iface_nodes; if(interface_1D -> type != 0){ /* TAN or NOR interface_1D */ entity -> dirs = (point_rec *)calloc(iface_nodes, sizeof(point_rec)); if(entity -> dirs == NULL)error_message("Memory allocation error", MEMORY_ERROR); read_tan_nor = YES; break; } } } interface_1D = NULL; } } if(read_tan_nor == YES){ switch(entity_type){ case CURVE_ENTITY: case SURFACE_ENTITY: case PATCH_ENTITY: case SHELL_ENTITY: break; default: error_message("Unexpected situation", GENERAL_ERROR); break; } } } if(entity -> first_node == 0)entity -> first_node = node_id; /* relevant only for native t3d output without renumbering !!! */ entity -> nodes++; if(read_tan_nor == YES){ if(sscanf(line_buf, "%lf %lf %lf", &xx, &yy, &zz) != 3) error_message(in_err_msg, FILE_READ_ERROR); } if(entity -> lcs != NULL && lcs_spec == YES){ if(entity -> lcs -> entity_id == 0){ /* primary LCS */ vec[0].x = xx; vec[0].y = yy; vec[0].z = zz; } else{ vec[0].x = vec[0].y = vec[0].z = 0.0; /* secondary LCS */ // to be completed when t3d will offer output of secondary tangents and normals } size = sqrt(vec[0].x * vec[0].x + vec[0].y * vec[0].y + vec[0].z * vec[0].z); if(size != 0.0){ if(fabs(size - 1.0)> 1.0e-5)error_message("Unexpected situation", GENERAL_ERROR); vec[1].x = entity -> lcs -> ref_vector.x; vec[1].y = entity -> lcs -> ref_vector.y; vec[1].z = entity -> lcs -> ref_vector.z; vec[2].x = vec[0].y * vec[1].z - vec[0].z * vec[1].y; vec[2].y = vec[0].z * vec[1].x - vec[0].x * vec[1].z; vec[2].z = vec[0].x * vec[1].y - vec[0].y * vec[1].x; size = sqrt(vec[2].x * vec[2].x + vec[2].y * vec[2].y + vec[2].z * vec[2].z); if(size < 1.0e-10) size = 0.0; else{ vec[1].x = vec[2].y * vec[0].z - vec[2].z * vec[0].y; vec[1].y = vec[2].z * vec[0].x - vec[2].x * vec[0].z; vec[1].z = vec[2].x * vec[0].y - vec[2].y * vec[0].x; } } } if(interface_1D != NULL){ if(entity -> nodes> iface_nodes) error_message("Unexpected situation", GENERAL_ERROR); /* number of nodes on opposite parts of interface_1D differs */ /* it is assumed that counterpart curves, surfaces/pathes/shells of 1D interface are geometrically identical and mirrored; otherwise it would be meaningless to store tangent or normal from just one side of curve, surface/patch/shell interface_1D; if nodes are stored (they are not) I could check coincidence if corresponding nodes; if an entity is forming two or more 1D interfaces and if at least one countepart appears in t3d output file after the entity, then tangent/normal is available for both corresponding nodes */ entity -> dirs[entity -> nodes - 1].x = xx; entity -> dirs[entity -> nodes - 1].y = yy; entity -> dirs[entity -> nodes - 1].z = zz; } if(singular == YES){ fe_node = &(fe_nodes[node_id - 1]); fe_node -> x = x; fe_node -> y = y; fe_node -> z = z; fe_node -> entity = entity; } if(entity -> node_type == NULL){ if(fprintf(oofem_in_file, "node %ld coords 3 %e %e %e", node_id, x, y, z) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM ordinary node record */ } else{ if(fprintf(oofem_in_file, "%s %ld coords 3 %e %e %e", entity -> node_type, node_id, x, y, z) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM special node record */ } if(entity -> lcs != NULL && lcs_spec == YES){ if(size != 0.0){ if(fprintf(oofem_in_file, " lcs 6 %e %e %e %e %e %e", vec[entity -> lcs -> lcs_x].x, vec[entity -> lcs -> lcs_x].y, vec[entity -> lcs -> lcs_x].z, vec[entity -> lcs -> lcs_y].x, vec[entity -> lcs -> lcs_y].y, vec[entity -> lcs -> lcs_y].z) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM node record */ } else{ fprintf(stderr, "Warning: Lcs at node %ld skipped due to ambiguity\n", node_id); } } node_list = entity -> node_prop_list; while(node_list != NULL){ string = (char *)(node_list -> item); node_list = node_list -> next; if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM node record */ } if(property_id> 0){ if(last_property_id != property_id){ ent = get_entity_id(property_list, property_id); last_property_id = property_id; } if(ent != NULL){ node_list = ent -> node_prop_list; while(node_list != NULL){ string = (char *)(node_list -> item); node_list = node_list -> next; if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM node record */ } } } if(fprintf(oofem_in_file, "\n") < 0)error_message(out_err_msg, FILE_WRITE_ERROR); } if(singular == YES){ /* get coordinates of singular nodes */ sing_list = singularity_list; while(sing_list != NULL){ singularity = (singularity_rec *)(sing_list -> item); sing_list = sing_list -> next; if(singularity -> node_id != 0){ fe_node = &(fe_nodes[singularity -> node_id - 1]); singularity -> center.x = fe_node -> x; singularity -> center.y = fe_node -> y; singularity -> center.z = fe_node -> z; } } } if(elem_degree == LINEAR){ if(edges != 0){ last_entity_type = 0; last_entity_id = 0; last_property_id = 0; for(i = 0; i < edges; i++){ get_next_relevant_record(in_err_msg); if(sscanf(line_buffer, "%ld %ld %ld %d %ld %ld", &elem_id, &node1_id, &node2_id, &entity_type, &entity_id, &property_id) != 6) error_message(in_err_msg, FILE_READ_ERROR); if(last_entity_type != entity_type || last_entity_id != entity_id){ switch(entity_type){ case CURVE_ENTITY: key = CURVE; entity_list = curve_list; break; case INTERFACE_ENTITY: key = INTERFACE; entity_list = interface_list; break; default: error_message("Invalid edge entity detected", GENERAL_ERROR); break; } entity = get_entity_id(entity_list, entity_id); /* the following should not be relevant */ if(entity == NULL)entity = create_missing_entity_id(entity_id, entity_type); if(entity -> selected == NO){ #ifdef DEFAULT_FIRST entity -> elem_prop_list = reverse_list(entity -> elem_prop_list); #endif process_entity(entity, entity_type); } elem_type = entity -> edge_type; if(elem_type == NULL)elem_type = entity -> elem_type; /* for compatibility reasons */ if(elem_type == NULL){ sprintf(err_msg, "Element type specification for edges on %s %ld missing", keyword[key], entity_id); error_message(err_msg, GENERAL_ERROR); } last_entity_type = entity_type; last_entity_id = entity_id; entity -> on_output = YES; } inside = NO; if(singular == YES && entity_type != INTERFACE_ENTITY){ nds = 0; node_array[nds++] = node1_id; node_array[nds++] = node2_id; for(j = 0; j < nds; j++){ if(node_array[j] <= 0 || node_array[j]> nodes){ sprintf(err_msg, "Invalid node number (%ld) of edge %ld", node_array[j], elem_id); error_message(err_msg, GENERAL_ERROR); } } inside = check_inside_singularity(entity, nds, node_array); } entity -> elems++; if(fprintf(oofem_in_file, "%s %ld nodes 2 %ld %ld", elem_type, elem_id, node1_id, node2_id) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ elem_list = entity -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[CURVE], entity_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } if(property_id> 0){ if(last_property_id != property_id){ ent = get_entity_id(property_list, property_id); last_property_id = property_id; } if(ent != NULL){ elem_list = ent -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[PROPERTY], property_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } } } if((load_id_list = entity -> bload_id_list) != NULL){ count = get_list_size(load_id_list); if(fprintf(oofem_in_file, " boundaryLoads %ld", count * 2) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %ld %d", *(long *)(load_id_list -> item), 1) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ load_id_list = load_id_list -> next; } } if(fprintf(oofem_in_file, "\n") < 0)error_message(out_err_msg, FILE_WRITE_ERROR); } } if(trias != 0){ last_entity_type = 0; last_entity_id = 0; last_property_id = 0; for(i = 0; i < trias; i++){ get_next_relevant_record(in_err_msg); num = sscanf(line_buffer, "%ld %ld %ld %ld %d %ld %ld %ld %ld %ld %ld %ld %ld", &elem_id, &node1_id, &node2_id, &node3_id, &entity_type, &entity_id, &property_id, &bound_cur_id[0], &bound_cur_id[1], &bound_cur_id[2], &bound_cur_prop[0], &bound_cur_prop[1], &bound_cur_prop[2]); if(num != 10 && num != 13) error_message(in_err_msg, FILE_READ_ERROR); bnd_prop = (num == 13) ? YES : NO; if(last_entity_type != entity_type || last_entity_id != entity_id){ switch(entity_type){ case SURFACE_ENTITY: key = SURFACE; entity_list = surface_list; break; case PATCH_ENTITY: key = PATCH; entity_list = patch_list; break; case SHELL_ENTITY: key = SHELL; entity_list = shell_list; break; default: error_message("Invalid triangle entity detected", GENERAL_ERROR); break; } entity = get_entity_id(entity_list, entity_id); /* the following should not be relevant */ if(entity == NULL)entity = create_missing_entity_id(entity_id, entity_type); if(entity -> selected == NO){ #ifdef DEFAULT_FIRST entity -> elem_prop_list = reverse_list(entity -> elem_prop_list); #endif process_entity(entity, entity_type); } elem_type = entity -> tria_type; if(elem_type == NULL)elem_type = entity -> elem_type; /* for compatibility reasons */ if(elem_type == NULL){ sprintf(err_msg, "Element type specification for trias on %s %ld missing", keyword[key], entity_id); error_message(err_msg, GENERAL_ERROR); } last_entity_type = entity_type; last_entity_id = entity_id; entity -> on_output = YES; } /* check whether bload and bcode has been processed on particular edge */ edge_flag[0] = get_linear_edge_flag(node1_id, node2_id, bound_cur_id[0]); edge_flag[1] = get_linear_edge_flag(node2_id, node3_id, bound_cur_id[1]); edge_flag[2] = get_linear_edge_flag(node3_id, node1_id, bound_cur_id[2]); inside = NO; if(singular == YES){ nds = 0; node_array[nds++] = node1_id; node_array[nds++] = node2_id; node_array[nds++] = node3_id; for(j = 0; j < nds; j++){ if(node_array[j] <= 0 || node_array[j]> nodes){ sprintf(err_msg, "Invalid node number (%ld) of tria %ld", node_array[j], elem_id); error_message(err_msg, GENERAL_ERROR); } } inside = check_inside_singularity(entity, nds, node_array); } entity -> elems++; if(fprintf(oofem_in_file, "%s %ld nodes 3 %ld %ld %ld", elem_type, elem_id, node1_id, node2_id, node3_id) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ elem_list = entity -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[key], entity_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } if(property_id> 0){ if(last_property_id != property_id){ ent = get_entity_id(property_list, property_id); last_property_id = property_id; } if(ent != NULL){ elem_list = ent -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[PROPERTY], property_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } } } count = 0; for(j = 0; j < 3; j++){ bflag[j] = NO; if(bound_cur_id[j] != 0 && edge_flag[j] == NO){ bflag[j] = YES; if((ent = get_entity_id(curve_list, bound_cur_id[j])) != NULL){ if(ent -> bload_id_list != NULL) count += get_list_size(ent -> bload_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if(count != 0){ if(fprintf(oofem_in_file, " boundaryLoads %ld", count * 2) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 3; j++){ if(bflag[j] == NO)continue; ent = get_entity_id(curve_list, bound_cur_id[j]); load_id_list = ent -> bload_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %ld %d", *(long *)(load_id_list -> item), j + 1) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ load_id_list = load_id_list -> next; } } } count = 0; for(j = 0; j < 3; j++){ bflag[j] = NO; if(bound_cur_id[j] != 0 && edge_flag[j] == NO){ bflag[j] = YES; if((ent = get_entity_id(curve_list, bound_cur_id[j])) != NULL){ if(ent -> bcode_id_list != NULL) count += get_list_size(ent -> bcode_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if(count != 0){ if(fprintf(oofem_in_file, " bsides %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 3; j++){ if(bflag[j] == NO)continue; ent = get_entity_id(curve_list, bound_cur_id[j]); code_id_list = ent -> bcode_id_list; while(code_id_list != NULL){ if(fprintf(oofem_in_file, " %d", j + 1) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } if(fprintf(oofem_in_file, " bcodes %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 3; j++){ if(bflag[j] == NO)continue; ent = get_entity_id(curve_list, bound_cur_id[j]); code_id_list = ent -> bcode_id_list; while(code_id_list != NULL){ if(fprintf(oofem_in_file, " %ld", *(long *)(code_id_list -> item)) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } } if(fprintf(oofem_in_file, "\n") < 0)error_message(out_err_msg, FILE_WRITE_ERROR); } } if(quads != 0){ last_entity_type = 0; last_entity_id = 0; last_property_id = 0; for(i = 0; i < quads; i++){ get_next_relevant_record(in_err_msg); num = sscanf(line_buffer, "%ld %ld %ld %ld %ld %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", &elem_id, &node1_id, &node2_id, &node3_id, &node4_id, &entity_type, &entity_id, &property_id, &bound_cur_id[0], &bound_cur_id[1], &bound_cur_id[2], &bound_cur_id[3], &bound_cur_prop[0], &bound_cur_prop[1], &bound_cur_prop[2], &bound_cur_prop[3]); if(num != 12 && num != 16) error_message(in_err_msg, FILE_READ_ERROR); bnd_prop = (num == 16) ? YES : NO; if(last_entity_type != entity_type || last_entity_id != entity_id){ switch(entity_type){ case SURFACE_ENTITY: key = SURFACE; entity_list = surface_list; break; case PATCH_ENTITY: key = PATCH; entity_list = patch_list; break; case SHELL_ENTITY: key = SHELL; entity_list = shell_list; break; case INTERFACE_ENTITY: key = INTERFACE; entity_list = interface_list; break; default: error_message("Invalid quadrilateral entity detected", GENERAL_ERROR); break; } entity = get_entity_id(entity_list, entity_id); /* the following should not be relevant */ if(entity == NULL)entity = create_missing_entity_id(entity_id, entity_type); if(entity -> selected == NO){ #ifdef DEFAULT_FIRST entity -> elem_prop_list = reverse_list(entity -> elem_prop_list); #endif process_entity(entity, entity_type); } elem_type = entity -> quad_type; if(elem_type == NULL && entity_type == INTERFACE_ENTITY)elem_type = entity -> elem_type; if(elem_type == NULL){ sprintf(err_msg, "Element type specification for quads on %s %ld missing", keyword[key], entity_id); error_message(err_msg, GENERAL_ERROR); } last_entity_type = entity_type; last_entity_id = entity_id; entity -> on_output = YES; } if(entity_type != INTERFACE_ENTITY){ /* check whether bload and bcode has been processed on particular edge */ edge_flag[0] = get_linear_edge_flag(node1_id, node2_id, bound_cur_id[0]); edge_flag[1] = get_linear_edge_flag(node2_id, node3_id, bound_cur_id[1]); edge_flag[2] = get_linear_edge_flag(node3_id, node4_id, bound_cur_id[2]); edge_flag[3] = get_linear_edge_flag(node4_id, node1_id, bound_cur_id[3]); } inside = NO; if(singular == YES && entity_type != INTERFACE_ENTITY){ nds = 0; node_array[nds++] = node1_id; node_array[nds++] = node2_id; node_array[nds++] = node3_id; node_array[nds++] = node4_id; for(j = 0; j < nds; j++){ if(node_array[j] <= 0 || node_array[j]> nodes){ sprintf(err_msg, "Invalid node number (%ld) of quad %ld", node_array[j], elem_id); error_message(err_msg, GENERAL_ERROR); } } inside = check_inside_singularity(entity, nds, node_array); } entity -> elems++; if(entity_type != INTERFACE_ENTITY){ if(fprintf(oofem_in_file, "%s %ld nodes 4 %ld %ld %ld %ld", elem_type, elem_id, node1_id, node2_id, node3_id, node4_id) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(fprintf(oofem_in_file, "%s %ld nodes 4 %ld %ld %ld %ld", elem_type, elem_id, node1_id, node2_id, node4_id, node3_id) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } elem_list = entity -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[key], entity_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } if(property_id> 0){ if(last_property_id != property_id){ ent = get_entity_id(property_list, property_id); last_property_id = property_id; } if(ent != NULL){ elem_list = ent -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[PROPERTY], property_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } } } if(entity_type != INTERFACE_ENTITY){ count = 0; for(j = 0; j < 4; j++){ bflag[j] = NO; if(bound_cur_id[j] != 0 && edge_flag[j] == NO){ bflag[j] = YES; if((ent = get_entity_id(curve_list, bound_cur_id[j])) != NULL){ if(ent -> bload_id_list != NULL) count += get_list_size(ent -> bload_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if(count != 0){ if(fprintf(oofem_in_file, " boundaryLoads %ld", count * 2) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 4; j++){ if(bflag[j] == NO)continue; ent = get_entity_id(curve_list, bound_cur_id[j]); load_id_list = ent -> bload_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %ld %d", *(long *)(load_id_list -> item), j + 1) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ load_id_list = load_id_list -> next; } } } count = 0; for(j = 0; j < 4; j++){ bflag[j] = NO; if(bound_cur_id[j] != 0 && edge_flag[j] == NO){ bflag[j] = YES; if((ent = get_entity_id(curve_list, bound_cur_id[j])) != NULL){ if(ent -> bcode_id_list != NULL) count += get_list_size(ent -> bcode_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if(count != 0){ if(fprintf(oofem_in_file, " bsides %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 4; j++){ if(bflag[j] == NO)continue; ent = get_entity_id(curve_list, bound_cur_id[j]); code_id_list = ent -> bcode_id_list; while(code_id_list != NULL){ if(fprintf(oofem_in_file, " %d", j + 1) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } if(fprintf(oofem_in_file, " bcodes %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 4; j++){ if(bflag[j] == NO)continue; ent = get_entity_id(curve_list, bound_cur_id[j]); code_id_list = ent -> bcode_id_list; while(code_id_list != NULL){ if(fprintf(oofem_in_file, " %ld", *(long *)(code_id_list -> item)) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } } } if(fprintf(oofem_in_file, "\n") < 0)error_message(out_err_msg, FILE_WRITE_ERROR); } } if(tetras != 0){ last_entity_type = 0; last_entity_id = 0; last_property_id = 0; for(i = 0; i < tetras; i++){ get_next_relevant_record(in_err_msg); if((output_type & 512) == 0){ num = sscanf(line_buffer, "%ld %ld %ld %ld %ld %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", &elem_id, &node1_id, &node2_id, &node3_id, &node4_id, &entity_type, &entity_id, &property_id, &bound_ent_id[0], &bound_ent_id[1], &bound_ent_id[2], &bound_ent_id[3], &bound_ent_tp[0], &bound_ent_tp[1], &bound_ent_tp[2], &bound_ent_tp[3], &bound_ent_prop[0], &bound_ent_prop[1], &bound_ent_prop[2], &bound_ent_prop[3]); if(num != 16 && num != 20) error_message(in_err_msg, FILE_READ_ERROR); bnd_prop = (num == 20) ? YES : NO; } else{ if(sscanf(line_buffer, "%ld %ld %ld %ld %ld %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", &elem_id, &node1_id, &node2_id, &node3_id, &node4_id, &entity_type, &entity_id, &property_id, &bound_ent_id[0], &bound_ent_id[1], &bound_ent_id[2], &bound_ent_id[3], &bound_ent_tp[0], &bound_ent_tp[1], &bound_ent_tp[2], &bound_ent_tp[3], &bound_ent_prop[0], &bound_ent_prop[1], &bound_ent_prop[2], &bound_ent_prop[3], &bound_cur_id[0], &bound_cur_id[1], &bound_cur_id[2], &bound_cur_id[3], &bound_cur_id[4], &bound_cur_id[5], &bound_cur_prop[0], &bound_cur_prop[1], &bound_cur_prop[2], &bound_cur_prop[3], &bound_cur_prop[4], &bound_cur_prop[5]) != 32) error_message(in_err_msg, FILE_READ_ERROR); bnd_prop = YES; } if(last_entity_type != entity_type || last_entity_id != entity_id){ if(entity_type != REGION_ENTITY) error_message("Invalid tetrahedron entity detected", GENERAL_ERROR); entity = get_entity_id(region_list, entity_id); /* the following should not be relevant */ if(entity == NULL)entity = create_missing_entity_id(entity_id, entity_type); if(entity -> selected == NO){ #ifdef DEFAULT_FIRST entity -> elem_prop_list = reverse_list(entity -> elem_prop_list); #endif process_entity(entity, entity_type); } elem_type = entity -> tetra_type; if(elem_type == NULL)elem_type = entity -> elem_type; /* for compatibility reasons */ if(elem_type == NULL){ sprintf(err_msg, "Element type specification for tetras in %s %ld missing", keyword[REGION], entity_id); error_message(err_msg, GENERAL_ERROR); } last_entity_type = entity_type; last_entity_id = entity_id; entity -> on_output = YES; } inside = NO; if(singular == YES){ nds = 0; node_array[nds++] = node1_id; node_array[nds++] = node2_id; node_array[nds++] = node3_id; node_array[nds++] = node4_id; for(j = 0; j < nds; j++){ if(node_array[j] <= 0 || node_array[j]> nodes){ sprintf(err_msg, "Invalid node number (%ld) of tetra %ld", node_array[j], elem_id); error_message(err_msg, GENERAL_ERROR); } } inside = check_inside_singularity(entity, nds, node_array); } entity -> elems++; if(fprintf(oofem_in_file, "%s %ld nodes 4 %ld %ld %ld %ld", elem_type, elem_id, node1_id, node2_id, node3_id, node4_id) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ elem_list = entity -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[REGION], entity_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } if(property_id> 0){ if(last_property_id != property_id){ ent = get_entity_id(property_list, property_id); last_property_id = property_id; } if(ent != NULL){ elem_list = ent -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[PROPERTY], property_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } } } count = 0; for(j = 0; j < 4; j++){ bflag[j] = NO; if(bound_ent_id[j] != 0){ bflag[j] = YES; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } if((ent = get_entity_id(entity_list, bound_ent_id[j])) != NULL){ if(ent -> bload_id_list != NULL) count += get_list_size(ent -> bload_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if((output_type & 512) != 0){ /* check whether bload has been processed on particular edge */ edge_flag[0] = get_linear_edge_flag(node1_id, node2_id, bound_cur_id[0]); edge_flag[1] = get_linear_edge_flag(node2_id, node3_id, bound_cur_id[1]); edge_flag[2] = get_linear_edge_flag(node3_id, node1_id, bound_cur_id[2]); edge_flag[3] = get_linear_edge_flag(node1_id, node4_id, bound_cur_id[3]); edge_flag[4] = get_linear_edge_flag(node2_id, node4_id, bound_cur_id[4]); edge_flag[5] = get_linear_edge_flag(node3_id, node4_id, bound_cur_id[5]); for(j = 0; j < 6; j++){ cflag[j] = NO; if(bound_cur_id[j] != 0 && edge_flag[j] == NO){ cflag[j] = YES; if((ent = get_entity_id(curve_list, bound_cur_id[j])) != NULL){ if(ent -> bload_id_list != NULL) count += get_list_size(ent -> bload_id_list); else cflag[j] = NO; } else cflag[j] = NO; } } } if(count != 0){ if(fprintf(oofem_in_file, " boundaryLoads %ld", count * 2) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 4; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); load_id_list = ent -> bload_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %ld %d", *(long *)(load_id_list -> item), j + 1) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ load_id_list = load_id_list -> next; } } if((output_type & 512) != 0){ for(j = 0; j < 6; j++){ if(cflag[j] == NO)continue; ent = get_entity_id(curve_list, bound_cur_id[j]); load_id_list = ent -> bload_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %ld %d", *(long *)(load_id_list -> item), j + 1) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ load_id_list = load_id_list -> next; } } } } count = 0; for(j = 0; j < 4; j++){ bflag[j] = NO; if(bound_ent_id[j] != 0){ bflag[j] = YES; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } if((ent = get_entity_id(entity_list, bound_ent_id[j])) != NULL){ if(ent -> bcode_id_list != NULL) count += get_list_size(ent -> bcode_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if(count != 0){ if(fprintf(oofem_in_file, " bsides %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 4; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); code_id_list = ent -> bcode_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %d", j + 1) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } if(fprintf(oofem_in_file, " bcodes %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 4; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); code_id_list = ent -> bcode_id_list; while(code_id_list != NULL){ if(fprintf(oofem_in_file, " %ld", *(long *)(code_id_list -> item)) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } } if(fprintf(oofem_in_file, "\n") < 0)error_message(out_err_msg, FILE_WRITE_ERROR); } } if(pyrams != 0){ last_entity_type = 0; last_entity_id = 0; last_property_id = 0; for(i = 0; i < pyrams; i++){ get_next_relevant_record(in_err_msg); if((output_type & 512) == 0){ num = sscanf(line_buffer, "%ld %ld %ld %ld %ld %ld %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", &elem_id, &node1_id, &node2_id, &node3_id, &node4_id, &node5_id, &entity_type, &entity_id, &property_id, &bound_ent_id[0], &bound_ent_id[1], &bound_ent_id[2], &bound_ent_id[3], &bound_ent_id[4], &bound_ent_tp[0], &bound_ent_tp[1], &bound_ent_tp[2], &bound_ent_tp[3], &bound_ent_tp[4], &bound_ent_prop[0], &bound_ent_prop[1], &bound_ent_prop[2], &bound_ent_prop[3], &bound_ent_prop[4]); if(num != 19 && num != 24) error_message(in_err_msg, FILE_READ_ERROR); bnd_prop = (num == 24) ? YES : NO; } else{ if(sscanf(line_buffer, "%ld %ld %ld %ld %ld %ld %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", &elem_id, &node1_id, &node2_id, &node3_id, &node4_id, &node5_id, &entity_type, &entity_id, &property_id, &bound_ent_id[0], &bound_ent_id[1], &bound_ent_id[2], &bound_ent_id[3], &bound_ent_id[4], &bound_ent_tp[0], &bound_ent_tp[1], &bound_ent_tp[2], &bound_ent_tp[3], &bound_ent_tp[4], &bound_ent_prop[0], &bound_ent_prop[1], &bound_ent_prop[2], &bound_ent_prop[3], &bound_ent_prop[4], &bound_cur_id[0], &bound_cur_id[1], &bound_cur_id[2], &bound_cur_id[3], &bound_cur_id[4], &bound_cur_id[5], &bound_cur_id[6], &bound_cur_id[7], &bound_cur_prop[0], &bound_cur_prop[1], &bound_cur_prop[2], &bound_cur_prop[3], &bound_cur_prop[4], &bound_cur_prop[5], &bound_cur_prop[6], &bound_cur_prop[7]) != 40) error_message(in_err_msg, FILE_READ_ERROR); bnd_prop = YES; } if(last_entity_type != entity_type || last_entity_id != entity_id){ if(entity_type != REGION_ENTITY) error_message("Invalid pyramid entity detected", GENERAL_ERROR); entity = get_entity_id(region_list, entity_id); /* the following should not be relevant */ if(entity == NULL)entity = create_missing_entity_id(entity_id, entity_type); if(entity -> selected == NO){ #ifdef DEFAULT_FIRST entity -> elem_prop_list = reverse_list(entity -> elem_prop_list); #endif process_entity(entity, entity_type); } elem_type = entity -> pyram_type; if(elem_type == NULL)elem_type = entity -> elem_type; /* for compatibility reasons */ if(elem_type == NULL){ sprintf(err_msg, "Element type specification for pyrams in %s %ld missing", keyword[REGION], entity_id); error_message(err_msg, GENERAL_ERROR); } last_entity_type = entity_type; last_entity_id = entity_id; entity -> on_output = YES; } inside = NO; if(singular == YES){ nds = 0; node_array[nds++] = node1_id; node_array[nds++] = node2_id; node_array[nds++] = node3_id; node_array[nds++] = node4_id; node_array[nds++] = node5_id; for(j = 0; j < nds; j++){ if(node_array[j] <= 0 || node_array[j]> nodes){ sprintf(err_msg, "Invalid node number (%ld) of pyram %ld", node_array[j], elem_id); error_message(err_msg, GENERAL_ERROR); } } inside = check_inside_singularity(entity, nds, node_array); } entity -> elems++; if(fprintf(oofem_in_file, "%s %ld nodes 8 %ld %ld %ld %ld %ld %ld %ld %ld", elem_type, elem_id, node1_id, node2_id, node3_id, node4_id, node5_id, node5_id, node5_id, node5_id) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ elem_list = entity -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[REGION], entity_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } if(property_id> 0){ if(last_property_id != property_id){ ent = get_entity_id(property_list, property_id); last_property_id = property_id; } if(ent != NULL){ elem_list = ent -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[PROPERTY], property_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } } } count = 0; for(j = 0; j < 5; j++){ bflag[j] = NO; if(bound_ent_id[j] != 0){ bflag[j] = YES; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } if((ent = get_entity_id(entity_list, bound_ent_id[j])) != NULL){ if(ent -> bload_id_list != NULL) count += get_list_size(ent -> bload_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if((output_type & 512) != 0){ /* check whether bload has been processed on particular edge */ edge_flag[0] = get_linear_edge_flag(node1_id, node2_id, bound_cur_id[0]); edge_flag[1] = get_linear_edge_flag(node2_id, node3_id, bound_cur_id[1]); edge_flag[2] = get_linear_edge_flag(node3_id, node4_id, bound_cur_id[2]); edge_flag[3] = get_linear_edge_flag(node4_id, node1_id, bound_cur_id[3]); edge_flag[4] = get_linear_edge_flag(node1_id, node5_id, bound_cur_id[4]); edge_flag[5] = get_linear_edge_flag(node2_id, node5_id, bound_cur_id[5]); edge_flag[6] = get_linear_edge_flag(node3_id, node5_id, bound_cur_id[6]); edge_flag[7] = get_linear_edge_flag(node4_id, node5_id, bound_cur_id[7]); for(j = 0; j < 8; j++){ cflag[j] = NO; if(bound_cur_id[j] != 0 && edge_flag[j] == NO){ cflag[j] = YES; if((ent = get_entity_id(curve_list, bound_cur_id[j])) != NULL){ if(ent -> bload_id_list != NULL) count += get_list_size(ent -> bload_id_list); else cflag[j] = NO; } else cflag[j] = NO; } } } if(count != 0){ if(fprintf(oofem_in_file, " boundaryLoads %ld", count * 2) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 5; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); load_id_list = ent -> bload_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %ld %d", *(long *)(load_id_list -> item), p2h_fc[j]) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ load_id_list = load_id_list -> next; } } if((output_type & 512) != 0){ for(j = 0; j < 8; j++){ if(cflag[j] == NO)continue; ent = get_entity_id(curve_list, bound_cur_id[j]); load_id_list = ent -> bload_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %ld %d", *(long *)(load_id_list -> item), j + 1) < 0) /* p2h_ed[j] */ error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ load_id_list = load_id_list -> next; } } } } count = 0; for(j = 0; j < 5; j++){ bflag[j] = NO; if(bound_ent_id[j] != 0){ bflag[j] = YES; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } if((ent = get_entity_id(entity_list, bound_ent_id[j])) != NULL){ if(ent -> bcode_id_list != NULL) count += get_list_size(ent -> bcode_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if(count != 0){ if(fprintf(oofem_in_file, " bsides %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 5; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); code_id_list = ent -> bcode_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %d", p2h_fc[j]) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } if(fprintf(oofem_in_file, " bcodes %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 5; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); code_id_list = ent -> bcode_id_list; while(code_id_list != NULL){ if(fprintf(oofem_in_file, " %ld", *(long *)(code_id_list -> item)) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } } if(fprintf(oofem_in_file, "\n") < 0)error_message(out_err_msg, FILE_WRITE_ERROR); } } if(wedges != 0){ last_entity_type = 0; last_entity_id = 0; last_property_id = 0; for(i = 0; i < wedges; i++){ get_next_relevant_record(in_err_msg); if((output_type & 512) == 0){ num = sscanf(line_buffer, "%ld %ld %ld %ld %ld %ld %ld %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", &elem_id, &node1_id, &node2_id, &node3_id, &node4_id, &node5_id, &node6_id, &entity_type, &entity_id, &property_id, &bound_ent_id[0], &bound_ent_id[1], &bound_ent_id[2], &bound_ent_id[3], &bound_ent_id[4], &bound_ent_tp[0], &bound_ent_tp[1], &bound_ent_tp[2], &bound_ent_tp[3], &bound_ent_tp[4], &bound_ent_prop[0], &bound_ent_prop[1], &bound_ent_prop[2], &bound_ent_prop[3], &bound_ent_prop[4]); if(num != 20 && num != 25) error_message(in_err_msg, FILE_READ_ERROR); bnd_prop = (num == 25) ? YES : NO; } else{ if(sscanf(line_buffer, "%ld %ld %ld %ld %ld %ld %ld %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", &elem_id, &node1_id, &node2_id, &node3_id, &node4_id, &node5_id, &node6_id, &entity_type, &entity_id, &property_id, &bound_ent_id[0], &bound_ent_id[1], &bound_ent_id[2], &bound_ent_id[3], &bound_ent_id[4], &bound_ent_tp[0], &bound_ent_tp[1], &bound_ent_tp[2], &bound_ent_tp[3], &bound_ent_tp[4], &bound_ent_prop[0], &bound_ent_prop[1], &bound_ent_prop[2], &bound_ent_prop[3], &bound_ent_prop[4], &bound_cur_id[0], &bound_cur_id[1], &bound_cur_id[2], &bound_cur_id[3], &bound_cur_id[4], &bound_cur_id[5], &bound_cur_id[6], &bound_cur_id[7], &bound_cur_id[8], &bound_cur_prop[0], &bound_cur_prop[1], &bound_cur_prop[2], &bound_cur_prop[3], &bound_cur_prop[4], &bound_cur_prop[5], &bound_cur_prop[6], &bound_cur_prop[7], &bound_cur_prop[8]) != 43) error_message(in_err_msg, FILE_READ_ERROR); bnd_prop = YES; } if(last_entity_type != entity_type || last_entity_id != entity_id){ switch(entity_type){ case REGION_ENTITY: key = REGION; entity_list = region_list; break; case INTERFACE_ENTITY: key = INTERFACE; entity_list = interface_list; break; default: error_message("Invalid wedge entity detected", GENERAL_ERROR); break; } entity = get_entity_id(entity_list, entity_id); /* the following should not be relevant */ if(entity == NULL)entity = create_missing_entity_id(entity_id, entity_type); if(entity -> selected == NO){ #ifdef DEFAULT_FIRST entity -> elem_prop_list = reverse_list(entity -> elem_prop_list); #endif process_entity(entity, entity_type); } elem_type = entity -> wedge_type; if(elem_type == NULL)elem_type = entity -> elem_type; /* for compatibility reasons */ if(elem_type == NULL){ sprintf(err_msg, "Element type specification for wedges in %s %ld missing", keyword[key], entity_id); error_message(err_msg, GENERAL_ERROR); } last_entity_type = entity_type; last_entity_id = entity_id; entity -> on_output = YES; } inside = NO; if(singular == YES && entity_type != INTERFACE_ENTITY){ nds = 0; node_array[nds++] = node1_id; node_array[nds++] = node2_id; node_array[nds++] = node3_id; node_array[nds++] = node4_id; node_array[nds++] = node5_id; node_array[nds++] = node6_id; for(j = 0; j < nds; j++){ if(node_array[j] <= 0 || node_array[j]> nodes){ sprintf(err_msg, "Invalid node number (%ld) of wedge %ld", node_array[j], elem_id); error_message(err_msg, GENERAL_ERROR); } } inside = check_inside_singularity(entity, nds, node_array); } entity -> elems++; if(fprintf(oofem_in_file, "%s %ld nodes 8 %ld %ld %ld %ld %ld %ld %ld %ld", elem_type, elem_id, node1_id, node2_id, node3_id, node3_id, node4_id, node5_id, node6_id, node6_id) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ elem_list = entity -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[REGION], entity_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } if(property_id> 0){ if(last_property_id != property_id){ ent = get_entity_id(property_list, property_id); last_property_id = property_id; } if(ent != NULL){ elem_list = ent -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[PROPERTY], property_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } } } if(entity_type != INTERFACE_ENTITY){ count = 0; for(j = 0; j < 5; j++){ bflag[j] = NO; if(bound_ent_id[j] != 0){ bflag[j] = YES; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } if((ent = get_entity_id(entity_list, bound_ent_id[j])) != NULL){ if(ent -> bload_id_list != NULL) count += get_list_size(ent -> bload_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if((output_type & 512) != 0){ /* check whether bload has been processed on particular edge */ edge_flag[0] = get_linear_edge_flag(node1_id, node2_id, bound_cur_id[0]); edge_flag[1] = get_linear_edge_flag(node2_id, node3_id, bound_cur_id[1]); edge_flag[2] = get_linear_edge_flag(node3_id, node1_id, bound_cur_id[2]); edge_flag[3] = get_linear_edge_flag(node4_id, node5_id, bound_cur_id[3]); edge_flag[4] = get_linear_edge_flag(node5_id, node6_id, bound_cur_id[4]); edge_flag[5] = get_linear_edge_flag(node6_id, node4_id, bound_cur_id[5]); edge_flag[6] = get_linear_edge_flag(node1_id, node4_id, bound_cur_id[6]); edge_flag[7] = get_linear_edge_flag(node2_id, node5_id, bound_cur_id[7]); edge_flag[8] = get_linear_edge_flag(node3_id, node6_id, bound_cur_id[8]); for(j = 0; j < 9; j++){ cflag[j] = NO; if(bound_cur_id[j] != 0 && edge_flag[j] == NO){ cflag[j] = YES; if((ent = get_entity_id(curve_list, bound_cur_id[j])) != NULL){ if(ent -> bload_id_list != NULL) count += get_list_size(ent -> bload_id_list); else cflag[j] = NO; } else cflag[j] = NO; } } } if(count != 0){ if(fprintf(oofem_in_file, " boundaryLoads %ld", count * 2) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 5; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); load_id_list = ent -> bload_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %ld %d", *(long *)(load_id_list -> item), w2h_fc[j]) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ load_id_list = load_id_list -> next; } } if((output_type & 512) != 0){ for(j = 0; j < 9; j++){ if(cflag[j] == NO)continue; ent = get_entity_id(curve_list, bound_cur_id[j]); load_id_list = ent -> bload_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %ld %d", *(long *)(load_id_list -> item), w2h_ed[j]) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ load_id_list = load_id_list -> next; } } } } count = 0; for(j = 0; j < 5; j++){ bflag[j] = NO; if(bound_ent_id[j] != 0){ bflag[j] = YES; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } if((ent = get_entity_id(entity_list, bound_ent_id[j])) != NULL){ if(ent -> bcode_id_list != NULL) count += get_list_size(ent -> bcode_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if(count != 0){ if(fprintf(oofem_in_file, " bsides %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 5; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); code_id_list = ent -> bcode_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %d", w2h_fc[j]) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } if(fprintf(oofem_in_file, " bcodes %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 5; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); code_id_list = ent -> bcode_id_list; while(code_id_list != NULL){ if(fprintf(oofem_in_file, " %ld", *(long *)(code_id_list -> item)) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } } } if(fprintf(oofem_in_file, "\n") < 0)error_message(out_err_msg, FILE_WRITE_ERROR); } } if(hexas != 0){ last_entity_type = 0; last_entity_id = 0; last_property_id = 0; for(i = 0; i < hexas; i++){ get_next_relevant_record(in_err_msg); if((output_type & 512) == 0){ num = sscanf(line_buffer, "%ld %ld %ld %ld %ld %ld %ld %ld %ld %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", &elem_id, &node1_id, &node2_id, &node3_id, &node4_id, &node5_id, &node6_id, &node7_id, &node8_id, &entity_type, &entity_id, &property_id, &bound_ent_id[0], &bound_ent_id[1], &bound_ent_id[2], &bound_ent_id[3], &bound_ent_id[4], &bound_ent_id[5], &bound_ent_tp[0], &bound_ent_tp[1], &bound_ent_tp[2], &bound_ent_tp[3], &bound_ent_tp[4], &bound_ent_tp[5], &bound_ent_prop[0], &bound_ent_prop[1], &bound_ent_prop[2], &bound_ent_prop[3], &bound_ent_prop[4], &bound_ent_prop[5]); if(num != 24 && num != 30) error_message(in_err_msg, FILE_READ_ERROR); bnd_prop = (num == 30) ? YES : NO; } else{ if(sscanf(line_buffer, "%ld %ld %ld %ld %ld %ld %ld %ld %ld %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", &elem_id, &node1_id, &node2_id, &node3_id, &node4_id, &node5_id, &node6_id, &node7_id, &node8_id, &entity_type, &entity_id, &property_id, &bound_ent_id[0], &bound_ent_id[1], &bound_ent_id[2], &bound_ent_id[3], &bound_ent_id[4], &bound_ent_id[5], &bound_ent_tp[0], &bound_ent_tp[1], &bound_ent_tp[2], &bound_ent_tp[3], &bound_ent_tp[4], &bound_ent_tp[5], &bound_ent_prop[0], &bound_ent_prop[1], &bound_ent_prop[2], &bound_ent_prop[3], &bound_ent_prop[4], &bound_ent_prop[5], &bound_cur_id[0], &bound_cur_id[1], &bound_cur_id[2], &bound_cur_id[3], &bound_cur_id[4], &bound_cur_id[5], &bound_cur_id[6], &bound_cur_id[7], &bound_cur_id[8], &bound_cur_id[9], &bound_cur_id[10], &bound_cur_id[11], &bound_cur_prop[0], &bound_cur_prop[1], &bound_cur_prop[2], &bound_cur_prop[3], &bound_cur_prop[4], &bound_cur_prop[5], &bound_cur_prop[6], &bound_cur_prop[7], &bound_cur_prop[8], &bound_cur_prop[9], &bound_cur_prop[10], &bound_cur_prop[11]) != 54) error_message(in_err_msg, FILE_READ_ERROR); bnd_prop = YES; } if(last_entity_type != entity_type || last_entity_id != entity_id){ switch(entity_type){ case REGION_ENTITY: key = REGION; entity_list = region_list; break; case INTERFACE_ENTITY: key = INTERFACE; entity_list = interface_list; break; default: error_message("Invalid hexahedron entity detected", GENERAL_ERROR); break; } entity = get_entity_id(entity_list, entity_id); /* the following should not be relevant */ if(entity == NULL)entity = create_missing_entity_id(entity_id, entity_type); if(entity -> selected == NO){ #ifdef DEFAULT_FIRST entity -> elem_prop_list = reverse_list(entity -> elem_prop_list); #endif process_entity(entity, entity_type); } elem_type = entity -> hexa_type; if(elem_type == NULL)elem_type = entity -> elem_type; /* for compatibility reasons */ if(elem_type == NULL){ sprintf(err_msg, "Element type specification for hexas in %s %ld missing", keyword[key], entity_id); error_message(err_msg, GENERAL_ERROR); } last_entity_type = entity_type; last_entity_id = entity_id; entity -> on_output = YES; } inside = NO; if(singular == YES && entity_type != INTERFACE_ENTITY){ nds = 0; node_array[nds++] = node1_id; node_array[nds++] = node2_id; node_array[nds++] = node3_id; node_array[nds++] = node4_id; node_array[nds++] = node5_id; node_array[nds++] = node6_id; node_array[nds++] = node7_id; node_array[nds++] = node8_id; for(j = 0; j < nds; j++){ if(node_array[j] <= 0 || node_array[j]> nodes){ sprintf(err_msg, "Invalid node number (%ld) of hexa %ld", node_array[j], elem_id); error_message(err_msg, GENERAL_ERROR); } } inside = check_inside_singularity(entity, nds, node_array); } entity -> elems++; if(fprintf(oofem_in_file, "%s %ld nodes 8 %ld %ld %ld %ld %ld %ld %ld %ld", elem_type, elem_id, node1_id, node2_id, node3_id, node4_id, node5_id, node6_id, node7_id, node8_id) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ elem_list = entity -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[REGION], entity_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } if(property_id> 0){ if(last_property_id != property_id){ ent = get_entity_id(property_list, property_id); last_property_id = property_id; } if(ent != NULL){ elem_list = ent -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[PROPERTY], property_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } } } if(entity_type != INTERFACE_ENTITY){ count = 0; for(j = 0; j < 6; j++){ bflag[j] = NO; if(bound_ent_id[j] != 0){ bflag[j] = YES; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } if((ent = get_entity_id(entity_list, bound_ent_id[j])) != NULL){ if(ent -> bload_id_list != NULL) count += get_list_size(ent -> bload_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if((output_type & 512) != 0){ /* check whether bload has been processed on particular edge */ edge_flag[0] = get_linear_edge_flag(node1_id, node2_id, bound_cur_id[0]); edge_flag[1] = get_linear_edge_flag(node2_id, node3_id, bound_cur_id[1]); edge_flag[2] = get_linear_edge_flag(node3_id, node4_id, bound_cur_id[2]); edge_flag[3] = get_linear_edge_flag(node4_id, node1_id, bound_cur_id[3]); edge_flag[4] = get_linear_edge_flag(node5_id, node6_id, bound_cur_id[4]); edge_flag[5] = get_linear_edge_flag(node6_id, node7_id, bound_cur_id[5]); edge_flag[6] = get_linear_edge_flag(node7_id, node8_id, bound_cur_id[6]); edge_flag[7] = get_linear_edge_flag(node8_id, node5_id, bound_cur_id[7]); edge_flag[8] = get_linear_edge_flag(node1_id, node5_id, bound_cur_id[8]); edge_flag[9] = get_linear_edge_flag(node2_id, node6_id, bound_cur_id[9]); edge_flag[10] = get_linear_edge_flag(node3_id, node7_id, bound_cur_id[10]); edge_flag[11] = get_linear_edge_flag(node4_id, node8_id, bound_cur_id[11]); for(j = 0; j < 12; j++){ cflag[j] = NO; if(bound_cur_id[j] != 0 && edge_flag[j] == NO){ cflag[j] = YES; if((ent = get_entity_id(curve_list, bound_cur_id[j])) != NULL){ if(ent -> bload_id_list != NULL) count += get_list_size(ent -> bload_id_list); else cflag[j] = NO; } else cflag[j] = NO; } } } if(count != 0){ if(fprintf(oofem_in_file, " boundaryLoads %ld", count * 2) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 6; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); load_id_list = ent -> bload_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %ld %d", *(long *)(load_id_list -> item), j + 1) < 0) /* h2h_fc[j] */ error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ load_id_list = load_id_list -> next; } } if((output_type & 512) != 0){ for(j = 0; j < 12; j++){ if(cflag[j] == NO)continue; ent = get_entity_id(curve_list, bound_cur_id[j]); load_id_list = ent -> bload_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %ld %d", *(long *)(load_id_list -> item), h2h_ed[j]) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ load_id_list = load_id_list -> next; } } } } count = 0; for(j = 0; j < 6; j++){ bflag[j] = NO; if(bound_ent_id[j] != 0){ bflag[j] = YES; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } if((ent = get_entity_id(entity_list, bound_ent_id[j])) != NULL){ if(ent -> bcode_id_list != NULL) count += get_list_size(ent -> bcode_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if(count != 0){ if(fprintf(oofem_in_file, " bsides %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 6; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); code_id_list = ent -> bcode_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %d", j + 1) < 0) /* h2h_fc[j] */ error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } if(fprintf(oofem_in_file, " bcodes %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 6; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); code_id_list = ent -> bcode_id_list; while(code_id_list != NULL){ if(fprintf(oofem_in_file, " %ld", *(long *)(code_id_list -> item)) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } } } if(fprintf(oofem_in_file, "\n") < 0)error_message(out_err_msg, FILE_WRITE_ERROR); } } } if(elem_degree == QUADRATIC){ if(edges != 0){ last_entity_type = 0; last_entity_id = 0; last_property_id = 0; for(i = 0; i < edges; i++){ get_next_relevant_record(in_err_msg); if(sscanf(line_buffer, "%ld %ld %ld %ld %d %ld %ld", &elem_id, &node1_id, &node2_id, &nd1_id, &entity_type, &entity_id, &property_id) != 7) error_message(in_err_msg, FILE_READ_ERROR); if(last_entity_type != entity_type || last_entity_id != entity_id){ switch(entity_type){ case CURVE_ENTITY: key = CURVE; entity_list = curve_list; break; case INTERFACE_ENTITY: key = INTERFACE; entity_list = interface_list; break; default: error_message("Invalid edge entity detected", GENERAL_ERROR); break; } entity = get_entity_id(entity_list, entity_id); /* the following should not be relevant */ if(entity == NULL)entity = create_missing_entity_id(entity_id, entity_type); if(entity -> selected == NO){ #ifdef DEFAULT_FIRST entity -> elem_prop_list = reverse_list(entity -> elem_prop_list); #endif process_entity(entity, entity_type); } elem_type = entity -> edge_type; if(elem_type == NULL)elem_type = entity -> elem_type; /* for compatibility reasons */ if(elem_type == NULL){ sprintf(err_msg, "Element type specification for edges on %s %ld missing", keyword[key], entity_id); error_message(err_msg, GENERAL_ERROR); } last_entity_type = entity_type; last_entity_id = entity_id; entity -> on_output = YES; } inside = NO; if(singular == YES && entity_type != INTERFACE_ENTITY){ nds = 0; node_array[nds++] = node1_id; node_array[nds++] = node2_id; #ifndef ONLY_LINEAR_NODES node_array[nds++] = nd1_id; #endif for(j = 0; j < nds; j++){ if(node_array[j] <= 0 || node_array[j]> nodes){ sprintf(err_msg, "Invalid node number (%ld) of edge %ld", node_array[j], elem_id); error_message(err_msg, GENERAL_ERROR); } } inside = check_inside_singularity(entity, nds, node_array); } entity -> elems++; if(entity_type != INTERFACE_ENTITY){ if(fprintf(oofem_in_file, "%s %ld nodes 3 %ld %ld %ld", elem_type, elem_id, node1_id, node2_id, nd1_id) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(fprintf(oofem_in_file, "%s %ld nodes 2 %ld %ld", elem_type, elem_id, node1_id, node2_id) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } elem_list = entity -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[CURVE], entity_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } if(property_id> 0){ if(last_property_id != property_id){ ent = get_entity_id(property_list, property_id); last_property_id = property_id; } if(ent != NULL){ elem_list = ent -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[PROPERTY], property_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } } } if((load_id_list = entity -> bload_id_list) != NULL){ count = get_list_size(load_id_list); if(fprintf(oofem_in_file, " boundaryLoads %ld", count * 2) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %ld %d", *(long *)(load_id_list -> item), 1) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ load_id_list = load_id_list -> next; } } if(fprintf(oofem_in_file, "\n") < 0)error_message(out_err_msg, FILE_WRITE_ERROR); } } if(trias != 0){ last_entity_type = 0; last_entity_id = 0; last_property_id = 0; for(i = 0; i < trias; i++){ get_next_relevant_record(in_err_msg); num = sscanf(line_buffer, "%ld %ld %ld %ld %ld %ld %ld %d %ld %ld %ld %ld %ld %ld %ld %ld", &elem_id, &node1_id, &node2_id, &node3_id, &nd1_id, &nd2_id, &nd3_id, &entity_type, &entity_id, &property_id, &bound_cur_id[0], &bound_cur_id[1], &bound_cur_id[2], &bound_cur_prop[0], &bound_cur_prop[1], &bound_cur_prop[2]); if(num != 13 && num != 16) error_message(in_err_msg, FILE_READ_ERROR); bnd_prop = (num == 16) ? YES : NO; if(last_entity_type != entity_type || last_entity_id != entity_id){ switch(entity_type){ case SURFACE_ENTITY: key = SURFACE; entity_list = surface_list; break; case PATCH_ENTITY: key = PATCH; entity_list = patch_list; break; case SHELL_ENTITY: key = SHELL; entity_list = shell_list; break; default: error_message("Invalid triangle entity detected", GENERAL_ERROR); break; } entity = get_entity_id(entity_list, entity_id); /* the following should not be relevant */ if(entity == NULL)entity = create_missing_entity_id(entity_id, entity_type); if(entity -> selected == NO){ #ifdef DEFAULT_FIRST entity -> elem_prop_list = reverse_list(entity -> elem_prop_list); #endif process_entity(entity, entity_type); } elem_type = entity -> tria_type; if(elem_type == NULL)elem_type = entity -> elem_type; /* for compatibility reasons */ if(elem_type == NULL){ sprintf(err_msg, "Element type specification for trias on %s %ld missing", keyword[key], entity_id); error_message(err_msg, GENERAL_ERROR); } last_entity_type = entity_type; last_entity_id = entity_id; entity -> on_output = YES; } /* check whether bload and bcode has been processed on particular edge */ edge_flag[0] = get_quadratic_edge_flag(nd1_id); edge_flag[1] = get_quadratic_edge_flag(nd2_id); edge_flag[2] = get_quadratic_edge_flag(nd3_id); inside = NO; if(singular == YES){ nds = 0; node_array[nds++] = node1_id; node_array[nds++] = node2_id; node_array[nds++] = node3_id; #ifndef ONLY_LINEAR_NODES node_array[nds++] = nd1_id; node_array[nds++] = nd2_id; node_array[nds++] = nd3_id; #endif for(j = 0; j < nds; j++){ if(node_array[j] <= 0 || node_array[j]> nodes){ sprintf(err_msg, "Invalid node number (%ld) of tria %ld", node_array[j], elem_id); error_message(err_msg, GENERAL_ERROR); } } inside = check_inside_singularity(entity, nds, node_array); } entity -> elems++; if(fprintf(oofem_in_file, "%s %ld nodes 6 %ld %ld %ld %ld %ld %ld", elem_type, elem_id, node1_id, node2_id, node3_id, nd1_id, nd2_id, nd3_id) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ elem_list = entity -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[key], entity_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } if(property_id> 0){ if(last_property_id != property_id){ ent = get_entity_id(property_list, property_id); last_property_id = property_id; } if(ent != NULL){ elem_list = ent -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[PROPERTY], property_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } } } count = 0; for(j = 0; j < 3; j++){ bflag[j] = NO; if(bound_cur_id[j] != 0 && edge_flag[j] == NO){ bflag[j] = YES; if((ent = get_entity_id(curve_list, bound_cur_id[j])) != NULL){ if(ent -> bload_id_list != NULL) count += get_list_size(ent -> bload_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if(count != 0){ if(fprintf(oofem_in_file, " boundaryLoads %ld", count * 2) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 3; j++){ if(bflag[j] == NO)continue; ent = get_entity_id(curve_list, bound_cur_id[j]); load_id_list = ent -> bload_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %ld %d", *(long *)(load_id_list -> item), j + 1) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ load_id_list = load_id_list -> next; } } } count = 0; for(j = 0; j < 3; j++){ bflag[j] = NO; if(bound_cur_id[j] != 0){ bflag[j] = YES; if((ent = get_entity_id(curve_list, bound_cur_id[j])) != NULL){ if(ent -> bcode_id_list != NULL) count += get_list_size(ent -> bcode_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if(count != 0){ if(fprintf(oofem_in_file, " bsides %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 3; j++){ if(bflag[j] == NO)continue; ent = get_entity_id(curve_list, bound_cur_id[j]); code_id_list = ent -> bcode_id_list; while(code_id_list != NULL){ if(fprintf(oofem_in_file, " %d", j + 1) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } if(fprintf(oofem_in_file, " bcodes %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 3; j++){ if(bflag[j] == NO)continue; ent = get_entity_id(curve_list, bound_cur_id[j]); code_id_list = ent -> bcode_id_list; while(code_id_list != NULL){ if(fprintf(oofem_in_file, " %ld", *(long *)(code_id_list -> item)) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } } if(fprintf(oofem_in_file, "\n") < 0)error_message(out_err_msg, FILE_WRITE_ERROR); } } if(quads != 0){ last_entity_type = 0; last_entity_id = 0; last_property_id = 0; for(i = 0; i < quads; i++){ get_next_relevant_record(in_err_msg); num = sscanf(line_buffer, "%ld %ld %ld %ld %ld %ld %ld %ld %ld %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", &elem_id, &node1_id, &node2_id, &node3_id, &node4_id, &nd1_id, &nd2_id, &nd3_id, &nd4_id, &entity_type, &entity_id, &property_id, &bound_cur_id[0], &bound_cur_id[1], &bound_cur_id[2], &bound_cur_id[3], &bound_cur_prop[0], &bound_cur_prop[1], &bound_cur_prop[2], &bound_cur_prop[3]); if(num != 16 && num != 20) error_message(in_err_msg, FILE_READ_ERROR); bnd_prop = (num == 20) ? YES : NO; if(last_entity_type != entity_type || last_entity_id != entity_id){ switch(entity_type){ case SURFACE_ENTITY: key = SURFACE; entity_list = surface_list; break; case PATCH_ENTITY: key = PATCH; entity_list = patch_list; break; case SHELL_ENTITY: key = SHELL; entity_list = shell_list; break; case INTERFACE_ENTITY: key = INTERFACE; entity_list = interface_list; break; default: error_message("Invalid quarilateral entity detected", GENERAL_ERROR); break; } entity = get_entity_id(entity_list, entity_id); /* the following should not be relevant */ if(entity == NULL)entity = create_missing_entity_id(entity_id, entity_type); if(entity -> selected == NO){ #ifdef DEFAULT_FIRST entity -> elem_prop_list = reverse_list(entity -> elem_prop_list); #endif process_entity(entity, entity_type); } elem_type = entity -> quad_type; if(elem_type == NULL){ sprintf(err_msg, "Element type specification for quads on %s %ld missing", keyword[key], entity_id); error_message(err_msg, GENERAL_ERROR); } last_entity_type = entity_type; last_entity_id = entity_id; entity -> on_output = YES; } if(entity_type != INTERFACE_ENTITY){ /* check whether bload and bcode has been processed on particular edge */ edge_flag[0] = get_quadratic_edge_flag(nd1_id); edge_flag[1] = get_quadratic_edge_flag(nd2_id); edge_flag[2] = get_quadratic_edge_flag(nd3_id); edge_flag[3] = get_quadratic_edge_flag(nd4_id); } inside = NO; if(singular == YES && entity_type != INTERFACE_ENTITY){ nds = 0; node_array[nds++] = node1_id; node_array[nds++] = node2_id; node_array[nds++] = node3_id; node_array[nds++] = node4_id; #ifndef ONLY_LINEAR_NODES node_array[nds++] = nd1_id; node_array[nds++] = nd2_id; node_array[nds++] = nd3_id; node_array[nds++] = nd4_id; #endif for(j = 0; j < nds; j++){ if(node_array[j] <= 0 || node_array[j]> nodes){ sprintf(err_msg, "Invalid node number (%ld) of quad %ld", node_array[j], elem_id); error_message(err_msg, GENERAL_ERROR); } } inside = check_inside_singularity(entity, nds, node_array); } entity -> elems++; if(entity_type != INTERFACE_ENTITY){ if(fprintf(oofem_in_file, "%s %ld nodes 8 %ld %ld %ld %ld %ld %ld %ld %ld", elem_type, elem_id, node1_id, node2_id, node3_id, node4_id, nd1_id, nd2_id, nd3_id, nd4_id) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(fprintf(oofem_in_file, "%s %ld nodes 6 %ld %ld %ld %ld %ld %ld", elem_type, elem_id, node1_id, node2_id, nd1_id, node4_id, node3_id, nd3_id) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } elem_list = entity -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[key], entity_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } if(property_id> 0){ if(last_property_id != property_id){ ent = get_entity_id(property_list, property_id); last_property_id = property_id; } if(ent != NULL){ elem_list = ent -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[PROPERTY], property_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } } } if(entity_type != INTERFACE_ENTITY){ count = 0; for(j = 0; j < 4; j++){ bflag[j] = NO; if(bound_cur_id[j] != 0 && edge_flag[j] == NO){ bflag[j] = YES; if((ent = get_entity_id(curve_list, bound_cur_id[j])) != NULL){ if(ent -> bload_id_list != NULL) count += get_list_size(ent -> bload_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if(count != 0){ if(fprintf(oofem_in_file, " boundaryLoads %ld", count * 2) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 4; j++){ if(bflag[j] == NO)continue; ent = get_entity_id(curve_list, bound_cur_id[j]); load_id_list = ent -> bload_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %ld %d", *(long *)(load_id_list -> item), j + 1) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ load_id_list = load_id_list -> next; } } } count = 0; for(j = 0; j < 4; j++){ bflag[j] = NO; if(bound_cur_id[j] != 0){ bflag[j] = YES; if((ent = get_entity_id(curve_list, bound_cur_id[j])) != NULL){ if(ent -> bcode_id_list != NULL) count += get_list_size(ent -> bcode_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if(count != 0){ if(fprintf(oofem_in_file, " bsides %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 4; j++){ if(bflag[j] == NO)continue; ent = get_entity_id(curve_list, bound_cur_id[j]); code_id_list = ent -> bcode_id_list; while(code_id_list != NULL){ if(fprintf(oofem_in_file, " %d", j + 1) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } if(fprintf(oofem_in_file, " bcodes %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 4; j++){ if(bflag[j] == NO)continue; ent = get_entity_id(curve_list, bound_cur_id[j]); code_id_list = ent -> bcode_id_list; while(code_id_list != NULL){ if(fprintf(oofem_in_file, " %ld", *(long *)(code_id_list -> item)) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } } } if(fprintf(oofem_in_file, "\n") < 0)error_message(out_err_msg, FILE_WRITE_ERROR); } } if(tetras != 0){ last_entity_type = 0; last_entity_id = 0; last_property_id = 0; for(i = 0; i < tetras; i++){ get_next_relevant_record(in_err_msg); if((output_type & 512) == 0){ num = sscanf(line_buffer, "%ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", &elem_id, &node1_id, &node2_id, &node3_id, &node4_id, &nd1_id, &nd2_id, &nd3_id, &nd4_id, &nd5_id, &nd6_id, &entity_type, &entity_id, &property_id, &bound_ent_id[0], &bound_ent_id[1], &bound_ent_id[2], &bound_ent_id[3], &bound_ent_tp[0], &bound_ent_tp[1], &bound_ent_tp[2], &bound_ent_tp[3], &bound_ent_prop[0], &bound_ent_prop[1], &bound_ent_prop[2], &bound_ent_prop[3]); if(num != 22 && num != 26) error_message(in_err_msg, FILE_READ_ERROR); bnd_prop = (num == 26) ? YES : NO; } else{ if(sscanf(line_buffer, "%ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", &elem_id, &node1_id, &node2_id, &node3_id, &node4_id, &nd1_id, &nd2_id, &nd3_id, &nd4_id, &nd5_id, &nd6_id, &entity_type, &entity_id, &property_id, &bound_ent_id[0], &bound_ent_id[1], &bound_ent_id[2], &bound_ent_id[3], &bound_ent_tp[0], &bound_ent_tp[1], &bound_ent_tp[2], &bound_ent_tp[3], &bound_ent_prop[0], &bound_ent_prop[1], &bound_ent_prop[2], &bound_ent_prop[3], &bound_cur_id[0], &bound_cur_id[1], &bound_cur_id[2], &bound_cur_id[3], &bound_cur_id[4], &bound_cur_id[5], &bound_cur_prop[0], &bound_cur_prop[1], &bound_cur_prop[2], &bound_cur_prop[3], &bound_cur_prop[4], &bound_cur_prop[5]) != 38) error_message(in_err_msg, FILE_READ_ERROR); bnd_prop = YES; } if(last_entity_type != entity_type || last_entity_id != entity_id){ if(entity_type != REGION_ENTITY) error_message("Invalid tetrahedron entity detected", GENERAL_ERROR); entity = get_entity_id(region_list, entity_id); /* the following should not be relevant */ if(entity == NULL)entity = create_missing_entity_id(entity_id, entity_type); if(entity -> selected == NO){ #ifdef DEFAULT_FIRST entity -> elem_prop_list = reverse_list(entity -> elem_prop_list); #endif process_entity(entity, entity_type); } elem_type = entity -> tetra_type; if(elem_type == NULL)elem_type = entity -> elem_type; /* for compatibility reasons */ if(elem_type == NULL){ sprintf(err_msg, "Element type specification for tetras in %s %ld missing", keyword[REGION], entity_id); error_message(err_msg, GENERAL_ERROR); } last_entity_type = entity_type; last_entity_id = entity_id; entity -> on_output = YES; } inside = NO; if(singular == YES){ nds = 0; node_array[nds++] = node1_id; node_array[nds++] = node2_id; node_array[nds++] = node3_id; node_array[nds++] = node4_id; #ifndef ONLY_LINEAR_NODES node_array[nds++] = nd1_id; node_array[nds++] = nd2_id; node_array[nds++] = nd3_id; node_array[nds++] = nd4_id; node_array[nds++] = nd5_id; node_array[nds++] = nd6_id; #endif for(j = 0; j < nds; j++){ if(node_array[j] <= 0 || node_array[j]> nodes){ sprintf(err_msg, "Invalid node number (%ld) of tetra %ld", node_array[j], elem_id); error_message(err_msg, GENERAL_ERROR); } } inside = check_inside_singularity(entity, nds, node_array); } entity -> elems++; if(fprintf(oofem_in_file, "%s %ld nodes 10 %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", elem_type, elem_id, node1_id, node2_id, node3_id, node4_id, nd1_id, nd2_id, nd3_id, nd4_id, nd5_id, nd6_id) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ elem_list = entity -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[REGION], entity_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } if(property_id> 0){ if(last_property_id != property_id){ ent = get_entity_id(property_list, property_id); last_property_id = property_id; } if(ent != NULL){ elem_list = ent -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[PROPERTY], property_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } } } count = 0; for(j = 0; j < 4; j++){ bflag[j] = NO; if(bound_ent_id[j] != 0){ bflag[j] = YES; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } if((ent = get_entity_id(entity_list, bound_ent_id[j])) != NULL){ if(ent -> bload_id_list != NULL) count += get_list_size(ent -> bload_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if((output_type & 512) != 0){ /* check whether bload has been processed on particular edge */ edge_flag[0] = get_quadratic_edge_flag(nd1_id); edge_flag[1] = get_quadratic_edge_flag(nd2_id); edge_flag[2] = get_quadratic_edge_flag(nd3_id); edge_flag[3] = get_quadratic_edge_flag(nd4_id); edge_flag[4] = get_quadratic_edge_flag(nd5_id); edge_flag[5] = get_quadratic_edge_flag(nd6_id); for(j = 0; j < 6; j++){ cflag[j] = NO; if(bound_cur_id[j] != 0 && edge_flag[j] == NO){ cflag[j] = YES; if((ent = get_entity_id(curve_list, bound_cur_id[j])) != NULL){ if(ent -> bload_id_list != NULL) count += get_list_size(ent -> bload_id_list); else cflag[j] = NO; } else cflag[j] = NO; } } } if(count != 0){ if(fprintf(oofem_in_file, " boundaryLoads %ld", count * 2) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 4; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); load_id_list = ent -> bload_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %ld %d", *(long *)(load_id_list -> item), j + 1) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ load_id_list = load_id_list -> next; } } if((output_type & 512) != 0){ for(j = 0; j < 6; j++){ if(cflag[j] == NO)continue; ent = get_entity_id(curve_list, bound_cur_id[j]); load_id_list = ent -> bload_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %ld %d", *(long *)(load_id_list -> item), j + 1) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ load_id_list = load_id_list -> next; } } } } count = 0; for(j = 0; j < 4; j++){ bflag[j] = NO; if(bound_ent_id[j] != 0){ bflag[j] = YES; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } if((ent = get_entity_id(entity_list, bound_ent_id[j])) != NULL){ if(ent -> bcode_id_list != NULL) count += get_list_size(ent -> bcode_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if(count != 0){ if(fprintf(oofem_in_file, " bsides %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 4; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); code_id_list = ent -> bcode_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %d", j + 1) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } if(fprintf(oofem_in_file, " bcodes %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 4; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); code_id_list = ent -> bcode_id_list; while(code_id_list != NULL){ if(fprintf(oofem_in_file, " %ld", *(long *)(code_id_list -> item)) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } } if(fprintf(oofem_in_file, "\n") < 0)error_message(out_err_msg, FILE_WRITE_ERROR); } } if(pyrams != 0){ last_entity_type = 0; last_entity_id = 0; last_property_id = 0; for(i = 0; i < pyrams; i++){ get_next_relevant_record(in_err_msg); if((output_type & 512) == 0){ num = sscanf(line_buffer, "%ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", &elem_id, &node1_id, &node2_id, &node3_id, &node4_id, &node5_id, &nd1_id, &nd2_id, &nd3_id, &nd4_id, &nd5_id, &nd6_id, &nd7_id, &nd8_id, &entity_type, &entity_id, &property_id, &bound_ent_id[0], &bound_ent_id[1], &bound_ent_id[2], &bound_ent_id[3], &bound_ent_id[4], &bound_ent_tp[0], &bound_ent_tp[1], &bound_ent_tp[2], &bound_ent_tp[3], &bound_ent_tp[4], &bound_ent_prop[0], &bound_ent_prop[1], &bound_ent_prop[2], &bound_ent_prop[3], &bound_ent_prop[4]); if(num != 27 && num != 32) error_message(in_err_msg, FILE_READ_ERROR); bnd_prop = (num == 32) ? YES : NO; } else{ if(sscanf(line_buffer, "%ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", &elem_id, &node1_id, &node2_id, &node3_id, &node4_id, &node5_id, &nd1_id, &nd2_id, &nd3_id, &nd4_id, &nd5_id, &nd6_id, &nd7_id, &nd8_id, &entity_type, &entity_id, &property_id, &bound_ent_id[0], &bound_ent_id[1], &bound_ent_id[2], &bound_ent_id[3], &bound_ent_id[4], &bound_ent_tp[0], &bound_ent_tp[1], &bound_ent_tp[2], &bound_ent_tp[3], &bound_ent_tp[4], &bound_ent_prop[0], &bound_ent_prop[1], &bound_ent_prop[2], &bound_ent_prop[3], &bound_ent_prop[4], &bound_cur_id[0], &bound_cur_id[1], &bound_cur_id[2], &bound_cur_id[3], &bound_cur_id[4], &bound_cur_id[5], &bound_cur_id[6], &bound_cur_id[7], &bound_cur_prop[0], &bound_cur_prop[1], &bound_cur_prop[2], &bound_cur_prop[3], &bound_cur_prop[4], &bound_cur_prop[5], &bound_cur_prop[6], &bound_cur_prop[7]) != 48) error_message(in_err_msg, FILE_READ_ERROR); bnd_prop = YES; } if(last_entity_type != entity_type || last_entity_id != entity_id){ if(entity_type != REGION_ENTITY) error_message("Invalid pyramid entity detected", GENERAL_ERROR); entity = get_entity_id(region_list, entity_id); /* the following should not be relevant */ if(entity == NULL)entity = create_missing_entity_id(entity_id, entity_type); if(entity -> selected == NO){ #ifdef DEFAULT_FIRST entity -> elem_prop_list = reverse_list(entity -> elem_prop_list); #endif process_entity(entity, entity_type); } elem_type = entity -> pyram_type; if(elem_type == NULL)elem_type = entity -> elem_type; /* for compatibility reasons */ if(elem_type == NULL){ sprintf(err_msg, "Element type specification for pyrams in %s %ld missing", keyword[REGION], entity_id); error_message(err_msg, GENERAL_ERROR); } last_entity_type = entity_type; last_entity_id = entity_id; entity -> on_output = YES; } inside = NO; if(singular == YES){ nds = 0; node_array[nds++] = node1_id; node_array[nds++] = node2_id; node_array[nds++] = node3_id; node_array[nds++] = node4_id; node_array[nds++] = node5_id; #ifndef ONLY_LINEAR_NODES node_array[nds++] = nd1_id; node_array[nds++] = nd2_id; node_array[nds++] = nd3_id; node_array[nds++] = nd4_id; node_array[nds++] = nd5_id; node_array[nds++] = nd6_id; node_array[nds++] = nd7_id; node_array[nds++] = nd8_id; #endif for(j = 0; j < nds; j++){ if(node_array[j] <= 0 || node_array[j]> nodes){ sprintf(err_msg, "Invalid node number (%ld) of pyram %ld", node_array[j], elem_id); error_message(err_msg, GENERAL_ERROR); } } inside = check_inside_singularity(entity, nds, node_array); } entity -> elems++; if(fprintf(oofem_in_file, "%s %ld nodes 20 %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", elem_type, elem_id, node1_id, node2_id, node3_id, node4_id, node5_id, node5_id, node5_id, node5_id, nd1_id, nd2_id, nd3_id, nd4_id, node5_id, node5_id, node5_id, node5_id, nd5_id, nd6_id, nd7_id, nd8_id) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ elem_list = entity -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[REGION], entity_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } if(property_id> 0){ if(last_property_id != property_id){ ent = get_entity_id(property_list, property_id); last_property_id = property_id; } if(ent != NULL){ elem_list = ent -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[PROPERTY], property_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } } } count = 0; for(j = 0; j < 5; j++){ bflag[j] = NO; if(bound_ent_id[j] != 0){ bflag[j] = YES; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } if((ent = get_entity_id(entity_list, bound_ent_id[j])) != NULL){ if(ent -> bload_id_list != NULL) count += get_list_size(ent -> bload_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if((output_type & 512) != 0){ /* check whether bload has been processed on particular edge */ edge_flag[0] = get_quadratic_edge_flag(nd1_id); edge_flag[1] = get_quadratic_edge_flag(nd2_id); edge_flag[2] = get_quadratic_edge_flag(nd3_id); edge_flag[3] = get_quadratic_edge_flag(nd4_id); edge_flag[4] = get_quadratic_edge_flag(nd5_id); edge_flag[5] = get_quadratic_edge_flag(nd6_id); edge_flag[6] = get_quadratic_edge_flag(nd7_id); edge_flag[7] = get_quadratic_edge_flag(nd8_id); for(j = 0; j < 8; j++){ cflag[j] = NO; if(bound_cur_id[j] != 0 && edge_flag[j] == NO){ cflag[j] = YES; if((ent = get_entity_id(curve_list, bound_cur_id[j])) != NULL){ if(ent -> bload_id_list != NULL) count += get_list_size(ent -> bload_id_list); else cflag[j] = NO; } else cflag[j] = NO; } } } if(count != 0){ if(fprintf(oofem_in_file, " boundaryLoads %ld", count * 2) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 5; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); load_id_list = ent -> bload_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %ld %d", *(long *)(load_id_list -> item), p2h_fc[j]) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ load_id_list = load_id_list -> next; } } if((output_type & 512) != 0){ for(j = 0; j < 8; j++){ if(cflag[j] == NO)continue; ent = get_entity_id(curve_list, bound_cur_id[j]); load_id_list = ent -> bload_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %ld %d", *(long *)(load_id_list -> item), j + 1) < 0) /* p2h_ed[j] */ error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ load_id_list = load_id_list -> next; } } } } count = 0; for(j = 0; j < 5; j++){ bflag[j] = NO; if(bound_ent_id[j] != 0){ bflag[j] = YES; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } if((ent = get_entity_id(entity_list, bound_ent_id[j])) != NULL){ if(ent -> bcode_id_list != NULL) count += get_list_size(ent -> bcode_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if(count != 0){ if(fprintf(oofem_in_file, " bsides %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 5; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); code_id_list = ent -> bcode_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %d", p2h_fc[j]) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } if(fprintf(oofem_in_file, " bcodes %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 5; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); code_id_list = ent -> bcode_id_list; while(code_id_list != NULL){ if(fprintf(oofem_in_file, " %ld", *(long *)(code_id_list -> item)) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } } if(fprintf(oofem_in_file, "\n") < 0)error_message(out_err_msg, FILE_WRITE_ERROR); } } if(wedges != 0){ last_entity_type = 0; last_entity_id = 0; last_property_id = 0; for(i = 0; i < wedges; i++){ get_next_relevant_record(in_err_msg); if((output_type & 512) == 0){ num = sscanf(line_buffer, "%ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", &elem_id, &node1_id, &node2_id, &node3_id, &node4_id, &node5_id, &node6_id, &nd1_id, &nd2_id, &nd3_id, &nd4_id, &nd5_id, &nd6_id, &nd7_id, &nd8_id, &nd9_id, &entity_type, &entity_id, &property_id, &bound_ent_id[0], &bound_ent_id[1], &bound_ent_id[2], &bound_ent_id[3], &bound_ent_id[4], &bound_ent_tp[0], &bound_ent_tp[1], &bound_ent_tp[2], &bound_ent_tp[3], &bound_ent_tp[4], &bound_ent_prop[0], &bound_ent_prop[1], &bound_ent_prop[2], &bound_ent_prop[3], &bound_ent_prop[4]); if(num != 29 && num != 34) error_message(in_err_msg, FILE_READ_ERROR); bnd_prop = (num == 34) ? YES : NO; } else{ if(sscanf(line_buffer, "%ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", &elem_id, &node1_id, &node2_id, &node3_id, &node4_id, &node5_id, &node6_id, &nd1_id, &nd2_id, &nd3_id, &nd4_id, &nd5_id, &nd6_id, &nd7_id, &nd8_id, &nd9_id, &entity_type, &entity_id, &property_id, &bound_ent_id[0], &bound_ent_id[1], &bound_ent_id[2], &bound_ent_id[3], &bound_ent_id[4], &bound_ent_tp[0], &bound_ent_tp[1], &bound_ent_tp[2], &bound_ent_tp[3], &bound_ent_tp[4], &bound_ent_prop[0], &bound_ent_prop[1], &bound_ent_prop[2], &bound_ent_prop[3], &bound_ent_prop[4], &bound_cur_id[0], &bound_cur_id[1], &bound_cur_id[2], &bound_cur_id[3], &bound_cur_id[4], &bound_cur_id[5], &bound_cur_id[6], &bound_cur_id[7], &bound_cur_id[8], &bound_cur_prop[0], &bound_cur_prop[1], &bound_cur_prop[2], &bound_cur_prop[3], &bound_cur_prop[4], &bound_cur_prop[5], &bound_cur_prop[6], &bound_cur_prop[7], &bound_cur_prop[8]) != 52) error_message(in_err_msg, FILE_READ_ERROR); bnd_prop = YES; } if(last_entity_type != entity_type || last_entity_id != entity_id){ switch(entity_type){ case REGION_ENTITY: key = REGION; entity_list = region_list; break; case INTERFACE_ENTITY: key = INTERFACE; entity_list = interface_list; break; default: error_message("Invalid wedge entity detected", GENERAL_ERROR); break; } entity = get_entity_id(entity_list, entity_id); /* the following should not be relevant */ if(entity == NULL)entity = create_missing_entity_id(entity_id, entity_type); if(entity -> selected == NO){ #ifdef DEFAULT_FIRST entity -> elem_prop_list = reverse_list(entity -> elem_prop_list); #endif process_entity(entity, entity_type); } elem_type = entity -> wedge_type; if(elem_type == NULL)elem_type = entity -> elem_type; /* for compatibility reasons */ if(elem_type == NULL){ sprintf(err_msg, "Element type specification for wedges in %s %ld missing", keyword[key], entity_id); error_message(err_msg, GENERAL_ERROR); } last_entity_type = entity_type; last_entity_id = entity_id; entity -> on_output = YES; } inside = NO; if(singular == YES && entity_type != INTERFACE_ENTITY){ nds = 0; node_array[nds++] = node1_id; node_array[nds++] = node2_id; node_array[nds++] = node3_id; node_array[nds++] = node4_id; node_array[nds++] = node5_id; node_array[nds++] = node6_id; #ifndef ONLY_LINEAR_NODES node_array[nds++] = nd1_id; node_array[nds++] = nd2_id; node_array[nds++] = nd3_id; node_array[nds++] = nd4_id; node_array[nds++] = nd5_id; node_array[nds++] = nd6_id; node_array[nds++] = nd7_id; node_array[nds++] = nd8_id; node_array[nds++] = nd9_id; #endif for(j = 0; j < nds; j++){ if(node_array[j] <= 0 || node_array[j]> nodes){ sprintf(err_msg, "Invalid node number (%ld) of wedge %ld", node_array[j], elem_id); error_message(err_msg, GENERAL_ERROR); } } inside = check_inside_singularity(entity, nds, node_array); } entity -> elems++; if(entity_type != INTERFACE_ENTITY){ if(fprintf(oofem_in_file, "%s %ld nodes 20 %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", elem_type, elem_id, node1_id, node2_id, node3_id, node3_id, node4_id, node5_id, node6_id, node6_id, nd1_id, nd2_id, node3_id, nd3_id, nd4_id, nd5_id, node6_id, nd6_id, nd7_id, nd8_id, nd9_id, nd9_id) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(fprintf(oofem_in_file, "%s %ld nodes 16 %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", elem_type, elem_id, node1_id, node2_id, node3_id, node3_id, nd1_id, nd2_id, node3_id, nd3_id, node4_id, node5_id, node6_id, node6_id, nd4_id, nd5_id, node6_id, nd6_id) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } elem_list = entity -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[REGION], entity_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } if(property_id> 0){ if(last_property_id != property_id){ ent = get_entity_id(property_list, property_id); last_property_id = property_id; } if(ent != NULL){ elem_list = ent -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[PROPERTY], property_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } } } if(entity_type != INTERFACE_ENTITY){ count = 0; for(j = 0; j < 5; j++){ bflag[j] = NO; if(bound_ent_id[j] != 0){ bflag[j] = YES; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } if((ent = get_entity_id(entity_list, bound_ent_id[j])) != NULL){ if(ent -> bload_id_list != NULL) count += get_list_size(ent -> bload_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if((output_type & 512) != 0){ /* check whether bload has been processed on particular edge */ edge_flag[0] = get_quadratic_edge_flag(nd1_id); edge_flag[1] = get_quadratic_edge_flag(nd2_id); edge_flag[2] = get_quadratic_edge_flag(nd3_id); edge_flag[3] = get_quadratic_edge_flag(nd4_id); edge_flag[4] = get_quadratic_edge_flag(nd5_id); edge_flag[5] = get_quadratic_edge_flag(nd6_id); edge_flag[6] = get_quadratic_edge_flag(nd7_id); edge_flag[7] = get_quadratic_edge_flag(nd8_id); edge_flag[8] = get_quadratic_edge_flag(nd9_id); for(j = 0; j < 9; j++){ cflag[j] = NO; if(bound_cur_id[j] != 0 && edge_flag[j] == NO){ cflag[j] = YES; if((ent = get_entity_id(curve_list, bound_cur_id[j])) != NULL){ if(ent -> bload_id_list != NULL) count += get_list_size(ent -> bload_id_list); else cflag[j] = NO; } else cflag[j] = NO; } } } if(count != 0){ if(fprintf(oofem_in_file, " boundaryLoads %ld", count * 2) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 5; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); load_id_list = ent -> bload_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %ld %d", *(long *)(load_id_list -> item), w2h_fc[j]) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ load_id_list = load_id_list -> next; } } if((output_type & 512) != 0){ for(j = 0; j < 9; j++){ if(cflag[j] == NO)continue; ent = get_entity_id(curve_list, bound_cur_id[j]); load_id_list = ent -> bload_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %ld %d", *(long *)(load_id_list -> item), w2h_ed[j]) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ load_id_list = load_id_list -> next; } } } } count = 0; for(j = 0; j < 5; j++){ bflag[j] = NO; if(bound_ent_id[j] != 0){ bflag[j] = YES; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } if((ent = get_entity_id(entity_list, bound_ent_id[j])) != NULL){ if(ent -> bcode_id_list != NULL) count += get_list_size(ent -> bcode_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if(count != 0){ if(fprintf(oofem_in_file, " bsides %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 5; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); code_id_list = ent -> bcode_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %d", w2h_fc[j]) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } if(fprintf(oofem_in_file, " bcodes %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 5; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); code_id_list = ent -> bcode_id_list; while(code_id_list != NULL){ if(fprintf(oofem_in_file, " %ld", *(long *)(code_id_list -> item)) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } } } if(fprintf(oofem_in_file, "\n") < 0)error_message(out_err_msg, FILE_WRITE_ERROR); } } if(hexas != 0){ last_entity_type = 0; last_entity_id = 0; last_property_id = 0; for(i = 0; i < hexas; i++){ get_next_relevant_record(in_err_msg); if((output_type & 512) == 0){ num = sscanf(line_buffer, "%ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", &elem_id, &node1_id, &node2_id, &node3_id, &node4_id, &node5_id, &node6_id, &node7_id, &node8_id, &nd1_id, &nd2_id, &nd3_id, &nd4_id, &nd5_id, &nd6_id, &nd7_id, &nd8_id, &nd9_id, &nd10_id, &nd11_id, &nd12_id, &entity_type, &entity_id, &property_id, &bound_ent_id[0], &bound_ent_id[1], &bound_ent_id[2], &bound_ent_id[3], &bound_ent_id[4], &bound_ent_id[5], &bound_ent_tp[0], &bound_ent_tp[1], &bound_ent_tp[2], &bound_ent_tp[3], &bound_ent_tp[4], &bound_ent_tp[5], &bound_ent_prop[0], &bound_ent_prop[1], &bound_ent_prop[2], &bound_ent_prop[3], &bound_ent_prop[4], &bound_ent_prop[5]); if(num != 36 && num != 42) error_message(in_err_msg, FILE_READ_ERROR); bnd_prop = (num == 42) ? YES : NO; } else{ if(sscanf(line_buffer, "%ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", &elem_id, &node1_id, &node2_id, &node3_id, &node4_id, &node5_id, &node6_id, &node7_id, &node8_id, &nd1_id, &nd2_id, &nd3_id, &nd4_id, &nd5_id, &nd6_id, &nd7_id, &nd8_id, &nd9_id, &nd10_id, &nd11_id, &nd12_id, &entity_type, &entity_id, &property_id, &bound_ent_id[0], &bound_ent_id[1], &bound_ent_id[2], &bound_ent_id[3], &bound_ent_id[4], &bound_ent_id[5], &bound_ent_tp[0], &bound_ent_tp[1], &bound_ent_tp[2], &bound_ent_tp[3], &bound_ent_tp[4], &bound_ent_tp[5], &bound_ent_prop[0], &bound_ent_prop[1], &bound_ent_prop[2], &bound_ent_prop[3], &bound_ent_prop[4], &bound_ent_prop[5], &bound_cur_id[0], &bound_cur_id[1], &bound_cur_id[2], &bound_cur_id[3], &bound_cur_id[4], &bound_cur_id[5], &bound_cur_id[6], &bound_cur_id[7], &bound_cur_id[8], &bound_cur_id[9], &bound_cur_id[10], &bound_cur_id[11], &bound_cur_prop[0], &bound_cur_prop[1], &bound_cur_prop[2], &bound_cur_prop[3], &bound_cur_prop[4], &bound_cur_prop[5], &bound_cur_prop[6], &bound_cur_prop[7], &bound_cur_prop[8], &bound_cur_prop[9], &bound_cur_prop[10], &bound_cur_prop[11]) != 66) error_message(in_err_msg, FILE_READ_ERROR); bnd_prop = YES; } if(last_entity_type != entity_type || last_entity_id != entity_id){ switch(entity_type){ case REGION_ENTITY: key = REGION; entity_list = region_list; break; case INTERFACE_ENTITY: key = INTERFACE; entity_list = interface_list; break; default: error_message("Invalid hexahedron entity detected", GENERAL_ERROR); break; } entity = get_entity_id(region_list, entity_id); /* the following should not be relevant */ if(entity == NULL)entity = create_missing_entity_id(entity_id, entity_type); if(entity -> selected == NO){ #ifdef DEFAULT_FIRST entity -> elem_prop_list = reverse_list(entity -> elem_prop_list); #endif process_entity(entity, entity_type); } elem_type = entity -> hexa_type; if(elem_type == NULL)elem_type = entity -> elem_type; /* for compatibility reasons */ if(elem_type == NULL){ sprintf(err_msg, "Element type specification for hexas in %s %ld missing", keyword[key], entity_id); error_message(err_msg, GENERAL_ERROR); } last_entity_type = entity_type; last_entity_id = entity_id; entity -> on_output = YES; } inside = NO; if(singular == YES && entity_type != INTERFACE_ENTITY){ nds = 0; node_array[nds++] = node1_id; node_array[nds++] = node2_id; node_array[nds++] = node3_id; node_array[nds++] = node4_id; node_array[nds++] = node5_id; node_array[nds++] = node6_id; node_array[nds++] = node7_id; node_array[nds++] = node8_id; #ifndef ONLY_LINEAR_NODES node_array[nds++] = nd1_id; node_array[nds++] = nd2_id; node_array[nds++] = nd3_id; node_array[nds++] = nd4_id; node_array[nds++] = nd5_id; node_array[nds++] = nd6_id; node_array[nds++] = nd7_id; node_array[nds++] = nd8_id; node_array[nds++] = nd9_id; node_array[nds++] = nd10_id; node_array[nds++] = nd11_id; node_array[nds++] = nd12_id; #endif for(j = 0; j < nds; j++){ if(node_array[j] <= 0 || node_array[j]> nodes){ sprintf(err_msg, "Invalid node number (%ld) of hexa %ld", node_array[j], elem_id); error_message(err_msg, GENERAL_ERROR); } } inside = check_inside_singularity(entity, nds, node_array); } entity -> elems++; if(entity_type != INTERFACE_ENTITY){ if(fprintf(oofem_in_file, "%s %ld nodes 20 %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", elem_type, elem_id, node1_id, node2_id, node3_id, node4_id, node5_id, node6_id, node7_id, node8_id, nd1_id, nd2_id, nd3_id, nd4_id, nd5_id, nd6_id, nd7_id, nd8_id, nd9_id, nd10_id, nd11_id, nd12_id) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(fprintf(oofem_in_file, "%s %ld nodes 16 %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", elem_type, elem_id, node1_id, node2_id, node3_id, node4_id, nd1_id, nd2_id, nd3_id, nd4_id, node5_id, node6_id, node7_id, node8_id, nd5_id, nd6_id, nd7_id, nd8_id) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } elem_list = entity -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[REGION], entity_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } if(property_id> 0){ if(last_property_id != property_id){ ent = get_entity_id(property_list, property_id); last_property_id = property_id; } if(ent != NULL){ elem_list = ent -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(inside == NO){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } else{ if(write_fictitious_csect(string, csect, keyword[PROPERTY], property_id, oofem_in_file) == YES)inside = NO; if(inside == YES){ if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } } } } } if(entity_type != INTERFACE_ENTITY){ count = 0; for(j = 0; j < 6; j++){ bflag[j] = NO; if(bound_ent_id[j] != 0){ bflag[j] = YES; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } if((ent = get_entity_id(entity_list, bound_ent_id[j])) != NULL){ if(ent -> bload_id_list != NULL) count += get_list_size(ent -> bload_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if((output_type & 512) != 0){ /* check whether bload has been processed on particular edge */ edge_flag[0] = get_quadratic_edge_flag(nd1_id); edge_flag[1] = get_quadratic_edge_flag(nd2_id); edge_flag[2] = get_quadratic_edge_flag(nd3_id); edge_flag[3] = get_quadratic_edge_flag(nd4_id); edge_flag[4] = get_quadratic_edge_flag(nd5_id); edge_flag[5] = get_quadratic_edge_flag(nd6_id); edge_flag[6] = get_quadratic_edge_flag(nd7_id); edge_flag[7] = get_quadratic_edge_flag(nd8_id); edge_flag[8] = get_quadratic_edge_flag(nd9_id); edge_flag[9] = get_quadratic_edge_flag(nd10_id); edge_flag[10] = get_quadratic_edge_flag(nd11_id); edge_flag[11] = get_quadratic_edge_flag(nd12_id); for(j = 0; j < 12; j++){ cflag[j] = NO; if(bound_cur_id[j] != 0 && edge_flag[j] == NO){ cflag[j] = YES; if((ent = get_entity_id(curve_list, bound_cur_id[j])) != NULL){ if(ent -> bload_id_list != NULL) count += get_list_size(ent -> bload_id_list); else cflag[j] = NO; } else cflag[j] = NO; } } } if(count != 0){ if(fprintf(oofem_in_file, " boundaryLoads %ld", count * 2) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 6; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); load_id_list = ent -> bload_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %ld %d", *(long *)(load_id_list -> item), j + 1) < 0) /* h2h_fc[j] */ error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ load_id_list = load_id_list -> next; } } if((output_type & 512) != 0){ for(j = 0; j < 12; j++){ if(cflag[j] == NO)continue; ent = get_entity_id(curve_list, bound_cur_id[j]); load_id_list = ent -> bload_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %ld %d", *(long *)(load_id_list -> item), h2h_ed[j]) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ load_id_list = load_id_list -> next; } } } } count = 0; for(j = 0; j < 6; j++){ bflag[j] = NO; if(bound_ent_id[j] != 0){ bflag[j] = YES; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } if((ent = get_entity_id(entity_list, bound_ent_id[j])) != NULL){ if(ent -> bcode_id_list != NULL) count += get_list_size(ent -> bcode_id_list); else bflag[j] = NO; } else bflag[j] = NO; } } if(count != 0){ if(fprintf(oofem_in_file, " bsides %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 6; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); code_id_list = ent -> bcode_id_list; while(load_id_list != NULL){ if(fprintf(oofem_in_file, " %d", j + 1) < 0) /* h2h_fc[j] */ error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } if(fprintf(oofem_in_file, " bcodes %ld", count) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ for(j = 0; j < 6; j++){ if(bflag[j] == NO)continue; switch(bound_ent_tp[j]){ case SURFACE_ENTITY: entity_list = surface_list; break; case PATCH_ENTITY: entity_list = patch_list; break; case SHELL_ENTITY: entity_list = shell_list; break; default: error_message("Invalid entity type", GENERAL_ERROR); break; } ent = get_entity_id(entity_list, bound_ent_id[j]); code_id_list = ent -> bcode_id_list; while(code_id_list != NULL){ if(fprintf(oofem_in_file, " %ld", *(long *)(code_id_list -> item)) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ code_id_list = code_id_list -> next; } } } } if(fprintf(oofem_in_file, "\n") < 0)error_message(out_err_msg, FILE_WRITE_ERROR); } } } #ifdef DEFAULT_FIRST interface_1D_list = reverse_list(interface_1D_list); #endif iface_list = interface_1D_list; while(iface_list != NULL){ interface_1D = (interface_1D_rec *)(iface_list -> item); iface_list = iface_list -> next; #ifdef DEFAULT_FIRST interface_1D -> elem_prop_list = reverse_list(interface_1D -> elem_prop_list); #endif master_ent = interface_1D -> master; slave_ent = interface_1D -> slave; if(master_ent -> nodes != slave_ent -> nodes){ switch(master_ent -> type){ case VERTEX_ENTITY: sprintf(err_msg, "Vertices %ld and %ld of 1D interface are not compatible", master_ent -> id, slave_ent -> id); break; case CURVE_ENTITY: sprintf(err_msg, "Curves %ld and %ld of 1D interface are not compatible", master_ent -> id, slave_ent -> id); break; case SURFACE_ENTITY: sprintf(err_msg, "Surfaces %ld and %ld of 1D interface are not compatible", master_ent -> id, slave_ent -> id); break; case PATCH_ENTITY: sprintf(err_msg, "Patches %ld and %ld of 1D interface are not compatible", master_ent -> id, slave_ent -> id); break; case SHELL_ENTITY: sprintf(err_msg, "Shells %ld and %ld of 1D interface are not compatible", master_ent -> id, slave_ent -> id); break; default: break; } error_message(err_msg, GENERAL_ERROR); } if(interface_1D -> type / 2 * 2 == interface_1D -> type){ /* 0, 2, 4 */ xx = vec[0].x = interface_1D -> vector.x; yy = vec[0].y = interface_1D -> vector.y; zz = vec[0].z = interface_1D -> vector.z; } for(i = 0; i < master_ent -> nodes; i++){ if(interface_1D -> type != 0){ entity = (master_ent -> dirs != NULL) ? master_ent : slave_ent; if(entity -> dirs == NULL) error_message("Unexpected situation", GENERAL_ERROR); /* note: if dirs are available on both entities, I could check that dirs are identical (not done) */ xx = vec[1].x = entity -> dirs[i].x; yy = vec[1].y = entity -> dirs[i].y; zz = vec[1].z = entity -> dirs[i].z; switch(interface_1D -> type){ case 2: /* tan on surface = (nor x vector) x nor */ vec[2].x = vec[1].y * vec[0].z - vec[1].z * vec[0].y; vec[2].y = vec[1].z * vec[0].x - vec[1].x * vec[0].z; vec[2].z = vec[1].x * vec[0].y - vec[1].y * vec[0].x; xx = vec[2].y * vec[1].z - vec[2].z * vec[1].y; yy = vec[2].z * vec[1].x - vec[2].x * vec[1].z; zz = vec[2].x * vec[1].y - vec[2].y * vec[1].x; break; case 4: /* nor on curve = tan x vector */ xx = vec[1].y * vec[0].z - vec[1].z * vec[0].y; yy = vec[1].z * vec[0].x - vec[1].x * vec[0].z; zz = vec[1].x * vec[0].y - vec[1].y * vec[0].x; break; default: break; } } if(fprintf(oofem_in_file, "Interface1D %ld nodes 2 %ld %ld normal 3 %e %e %e", ++elem_id, master_ent -> first_node + i, slave_ent -> first_node + i, xx, yy, zz) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ elem_list = interface_1D -> elem_prop_list; while(elem_list != NULL){ string = (char *)(elem_list -> item); elem_list = elem_list -> next; if(fprintf(oofem_in_file, "%s", string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ } if(fprintf(oofem_in_file, "\n") < 0)error_message(out_err_msg, FILE_WRITE_ERROR); } } if(elem_id != elems + ifaces_1D) error_message("Unexpected situation", GENERAL_ERROR); rewind(active_in_file = control_file); sprintf(in_err_msg, "Unexpected end of control file %s", control_name); /* skip output file, problem description, analysis, metastep, modules, initmodules, xfemman, domain, output manager and component size records */ get_next_relevant_record(in_err_msg); get_next_relevant_record(in_err_msg); get_next_relevant_record(in_err_msg); for(i = 0; i < add_recs; i++)get_next_relevant_record(in_err_msg); /* OOFEM analysis additional records */ get_next_relevant_record(in_err_msg); get_next_relevant_record(in_err_msg); get_next_relevant_record(in_err_msg); #ifdef SINGULARITY if(singular == YES){ if(fprintf(oofem_in_file, "# fictitious cross sections have id> %d\n", csect) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM comment */ } #endif for(i = 0; i < csect; i++){ read_write_until_next_relevant_record(in_err_msg, out_err_msg); /* OOFEM cross section record */ #ifdef SINGULARITY if(singular == YES){ /* insert fictitious cross section record; I do rely on fact that oofem handles records according to its identification number */ string = line_buffer; while(*string == ' ' || *string == '\t')string++; while(*string != ' ' && *string != '\t' && *string != '0円' && *string != '\n' && *string != '\r')string++; if(*string == '0円' || *string == '\n' || *string == '\r')error_message("Incomplete cross section record", GENERAL_ERROR); str_ptr = string; while(*string == ' ' || *string == '\t')string++; sscanf(string, "%d", &csect_id); while(*string != ' ' && *string != '\t' && *string != '0円' && *string != '\n' && *string != '\r')string++; *str_ptr = '0円'; if(fprintf(oofem_in_file, "%s %d%s", line_buffer, csect_id + csect, string) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM fictitious cross section record */ } #endif } for(i = 0; i < mater; i++) read_write_until_next_relevant_record(in_err_msg, out_err_msg); /* OOFEM material record */ for(i = 0; i < barriers; i++) read_write_until_next_relevant_record(in_err_msg, out_err_msg); /* OOFEM nonlocal barrier record */ for(i = 0; i < randgens; i++) read_write_until_next_relevant_record(in_err_msg, out_err_msg); /* OOFEM random field generator record */ for(i = 0; i < bcond; i++) read_write_until_next_relevant_record(in_err_msg, out_err_msg); /* OOFEM boundary condition record */ for(i = 0; i < nic; i++) read_write_until_next_relevant_record(in_err_msg, out_err_msg); /* OOFEM initial condition record */ for(i = 0; i < timef; i++) read_write_until_next_relevant_record(in_err_msg, out_err_msg); /* OOFEM time function record */ /* copy OOFEM check section (hopefully it is independent of t3d2oofem) */ fprintf(oofem_in_file, "\n"); write_rec = NO; while(get_next_record(NULL)){ if(strncasecmp(line_buffer, "#%BEGIN_CHECK%", 14) == 0)write_rec = YES; if(write_rec == YES)write_current_record(out_err_msg); if(strncasecmp(line_buffer, "#%END_CHECK%", 12) == 0)break; } fclose(control_file); fclose(t3d_out_file); fclose(oofem_in_file); if(node_flag != NULL)free(node_flag); if(con_node1 != NULL)free(con_node1); if(con_node2 != NULL)free(con_node2); if(singular == YES){ if(fe_nodes != NULL)free(fe_nodes); } check_entity_list(vertex_list, keyword[VERTEX]); check_entity_list(curve_list, keyword[CURVE]); check_entity_list(surface_list, keyword[SURFACE]); check_entity_list(patch_list, keyword[PATCH]); check_entity_list(shell_list, keyword[SHELL]); check_entity_list(region_list, keyword[REGION]); check_entity_list(interface_list, keyword[INTERFACE]); if(singular == YES){ /* report number of elements included by singularities */ fprintf(stderr, "\n"); sing_list = reverse_list(singularity_list); while(sing_list != NULL){ singularity = (singularity_rec *)(sing_list -> item); sing_list = sing_list -> next; fprintf(stderr, "sing %e %e %e (%e): %ld\n", singularity -> center.x, singularity -> center.y, singularity -> center.z, singularity -> radius, singularity -> elems); } } destroy_entity_list(vertex_list); destroy_entity_list(curve_list); destroy_entity_list(surface_list); destroy_entity_list(patch_list); destroy_entity_list(shell_list); destroy_entity_list(region_list); destroy_entity_list(interface_list); destroy_entities_list(vertices_list); destroy_entities_list(curves_list); destroy_entities_list(surfaces_list); destroy_entities_list(patches_list); destroy_entities_list(shells_list); destroy_entities_list(regions_list); destroy_entities_list(interfaces_list); vertex_list = deep_destroy_list(vertex_list); curve_list = deep_destroy_list(curve_list); surface_list = deep_destroy_list(surface_list); patch_list = deep_destroy_list(patch_list); shell_list = deep_destroy_list(shell_list); region_list = deep_destroy_list(region_list); interface_list = deep_destroy_list(interface_list); vertices_list = deep_destroy_list(vertices_list); curves_list = deep_destroy_list(curves_list); surfaces_list = deep_destroy_list(surfaces_list); patches_list = deep_destroy_list(patches_list); shells_list = deep_destroy_list(shells_list); regions_list = deep_destroy_list(regions_list); interfaces_list = deep_destroy_list(interfaces_list); property_list = deep_destroy_list(property_list); string_list = deep_destroy_list(string_list); id_list = deep_destroy_list(id_list); singularity_list = deep_destroy_list(singularity_list); destroy_interface_1D_list(); interface_1D_list = deep_destroy_list(interface_1D_list); if(domain == YES){ sprintf(oofem_domain_name, "%s.domain", oofem_in_name); if((oofem_in_file = fopen(oofem_in_name, "r")) == NULL){ sprintf(err_msg, "File %s opening error", oofem_in_name); error_message(err_msg, FILE_OPEN_ERROR); } if((oofem_domain_file = fopen(oofem_domain_name, "w")) == NULL){ sprintf(err_msg, "File %s opening error", oofem_domain_name); error_message(err_msg, FILE_OPEN_ERROR); } active_in_file = oofem_in_file; active_out_file = oofem_domain_file; sprintf(in_err_msg, "Unexpected end of oofem in file %s", oofem_in_name); sprintf(out_err_msg, "File %s writing error", oofem_domain_name); get_next_relevant_record(in_err_msg); /* OOFEM output file record */ get_next_relevant_record(in_err_msg); /* OOFEM problem description record */ get_next_relevant_record(in_err_msg); /* OOFEM analysis type record */ for(i = 0; i < add_recs; i++)get_next_relevant_record(in_err_msg); /* OOFEM analysis additional records */ read_write_next_relevant_record(in_err_msg, out_err_msg); /* OOFEM domain record */ read_write_next_relevant_record(in_err_msg, out_err_msg); /* OOFEM output manager record */ read_write_next_relevant_record(in_err_msg, out_err_msg); /* OOFEM number record */ for(i = 0; i < nodes; i++) read_write_next_relevant_record(in_err_msg, out_err_msg); /* OOFEM node record */ for(i = 0; i < elems; i++) read_write_next_relevant_record(in_err_msg, out_err_msg); /* OOFEM elem record */ for(i = 0; i < csect; i++) read_write_next_relevant_record(in_err_msg, out_err_msg); /* OOFEM csect record */ for(i = 0; i < mater; i++) read_write_next_relevant_record(in_err_msg, out_err_msg); /* OOFEM mater record */ for(i = 0; i < bcond; i++) read_write_next_relevant_record(in_err_msg, out_err_msg); /* OOFEM bcond record */ for(i = 0; i < nic; i++) read_write_next_relevant_record(in_err_msg, out_err_msg); /* OOFEM icond record */ for(i = 0; i < timef; i++) read_write_next_relevant_record(in_err_msg, out_err_msg); /* OOFEM timef record */ fclose(oofem_in_file); fclose(oofem_domain_file); } if(warning == YES){ fprintf(stderr, "\nThe above warnings need not necessarily be an error\n"); fprintf(stderr, "(for example, there might be no internal node on an entity,\n"); fprintf(stderr, "or elements on boundary entities are not in output by default)\n"); fprintf(stderr, "but they are worth to be checked\n\n"); } if(ifaces_1D != 0){ fprintf(stderr, "WARNING: Number of elements in generated Oofem input file must be increased by %ld\n", ifaces_1D); fprintf(stderr, " to account for 1D interface elements !!!\n\n"); } return(0); } static list_rec * add_item_to_list_head(list_rec *any_list, void *item) { list_rec *lst = NULL; lst = (list_rec *)malloc(sizeof(list_rec)); if(lst == NULL)error_message("Memory allocation error", MEMORY_ERROR); lst -> item = item; lst -> next = any_list; return(lst); } static list_rec * deep_destroy_list(list_rec *any_list) { list_rec *lst = NULL; while(any_list != NULL){ if(any_list -> item != NULL)free(any_list -> item); any_list = (lst = any_list) -> next; free(lst); } return(NULL); } static list_rec * destroy_list(list_rec *any_list) { list_rec *lst = NULL; while(any_list != NULL){ any_list = (lst = any_list) -> next; free(lst); } return(NULL); } static list_rec * reverse_list(list_rec *any_list) { list_rec *head = NULL, *lst = NULL; if(any_list == NULL)return(NULL); if(any_list -> next == NULL)return(any_list); head = NULL; while((lst = any_list) != NULL){ any_list = any_list -> next; lst -> next = head; head = lst; } return(head); } static long get_list_size(list_rec *any_list) { long count = 0L; while(any_list != NULL){ any_list = any_list -> next; count++; } return(count); } static char * get_next_record(char *err_msg) { char *buf = NULL; if((buf = fgets(line_buffer, BUFFER_SIZE, active_in_file)) == NULL){ if(!feof(active_in_file))error_message("Reading error", FILE_READ_ERROR); if(err_msg == NULL)return(NULL); error_message(err_msg, GENERAL_ERROR); } return(buf); } static char * get_next_relevant_record(char *err_msg) { char *buf = NULL, *character = NULL; do{ if((buf = get_next_record(err_msg)) == NULL)return(NULL); character = line_buffer; while(*character == ' ' || *character == '\t')character++; }while(*character == '\n' || *character == REMARK); return(buf); } static char * get_first_token(char *err_msg) { char *token = NULL, *buf = NULL; while(YES){ if((buf = get_next_relevant_record(err_msg)) == NULL)return(NULL); if((token = strtok(buf, SEPARATOR)) == NULL)continue; break; } return(token); } static char * get_next_token(char *err_msg) { char *token = NULL; if((token = strtok(NULL, SEPARATOR)) == NULL){ if(err_msg == NULL)return(NULL); error_message(err_msg, FILE_READ_ERROR); } if(*token == REMARK)return(NULL); return(token); } static int get_token_key(char *token, char keyword[1][KEY_SIZE], int keynum) { char *t = token; int key; if(KEY_CASE == UPPER_CASE){ while(*t != '0円'){ *t = (char)toupper((int)*t); t++; } } if(KEY_CASE == LOWER_CASE){ while(*t != '0円'){ *t = (char)tolower((int)*t); t++; } } /* do not use strcasecmp (it is not standard) */ for(key = 0; key < keynum; key++){ if(strcmp(token, keyword[key]) == 0) return(key); } return(keynum); } long get_next_int(char *err_msg) { return(get_int_from_token(get_next_token(err_msg))); } double get_next_fpn(char *err_msg) { return(get_fpn_from_token(get_next_token(err_msg))); } long get_int_from_token(char *token) { char *t_ptr = token, *t = token, err_msg[128]; long int_num; int_num = strtol(token, &t_ptr, 10); if(token == t_ptr || *t_ptr != '0円'){ sprintf(err_msg, "Integer number expected (\"%s\" - read)", t); error_message(err_msg, GENERAL_ERROR); } return(int_num); } double get_fpn_from_token(char *token) { char *t_ptr = token, *t = token, err_msg[128]; double fpn_num; fpn_num = strtod(token, &t_ptr); if(token == t_ptr || *t_ptr != '0円'){ sprintf(err_msg, "Floating point number expected (\"%s\" - read)", t); error_message(err_msg, GENERAL_ERROR); } return(fpn_num); } static void write_current_record(char *err_msg) { if(fprintf(active_out_file, "%s", line_buffer) < 0) error_message(err_msg, FILE_WRITE_ERROR); } static void read_write_next_relevant_record(char *in_err_msg, char *out_err_msg) { get_next_relevant_record(in_err_msg); write_current_record(out_err_msg); } static void read_write_unrelevant_records(char *in_err_msg, char *out_err_msg) { char *character = NULL; while(YES){ get_next_record(in_err_msg); character = line_buffer; while(*character == ' ' || *character == '\t')character++; if(*character != '\n' && *character != REMARK)break; write_current_record(out_err_msg); } } static void read_write_until_next_relevant_record(char *in_err_msg, char *out_err_msg) { read_write_unrelevant_records(in_err_msg, out_err_msg); write_current_record(out_err_msg); } static long * get_id(list_rec *id_list, long id) { long *ident = NULL; while(id_list != NULL){ ident = (long *)(id_list -> item); id_list = id_list -> next; if(*ident == id)return(ident); } return(NULL); } static long * create_id(long id) { long *ident = NULL; ident = (long *)malloc(sizeof(long)); if(ident == NULL)error_message("Memory allocation error", MEMORY_ERROR); *ident = id; return(ident); } static entity_rec * get_entity_id(list_rec *entity_list, long id) { entity_rec *ent = NULL; while(entity_list != NULL){ ent = (entity_rec *)(entity_list -> item); entity_list = entity_list -> next; if(ent -> id == id)return(ent); } return(NULL); } static entity_rec * create_entity_id(long id, int type) { entity_rec *ent = NULL; ent = (entity_rec *)malloc(sizeof(entity_rec)); if(ent == NULL)error_message("Memory allocation error", MEMORY_ERROR); ent -> id = id; ent -> type = type; ent -> selected = NO; ent -> node_prop_list = NULL; ent -> elem_prop_list = NULL; ent -> elem_type = NULL; ent -> edge_type = NULL; ent -> tria_type = NULL; ent -> quad_type = NULL; ent -> tetra_type = NULL; ent -> pyram_type = NULL; ent -> wedge_type = NULL; ent -> hexa_type = NULL; ent -> bload_id_list = NULL; ent -> bcode_id_list = NULL; ent -> node_type = NULL; ent -> first_node = 0; ent -> nodes = 0; ent -> elems = 0; ent -> on_output = NO; ent -> curve_id_list = NULL; ent -> singularity_list = NULL; ent -> lcs = NULL; ent -> interface_1D = NO; ent -> dirs = NULL; return(ent); } static entities_rec * create_entities(int type) { entities_rec *ents = NULL; ents = (entities_rec *)malloc(sizeof(entities_rec)); if(ents == NULL)error_message("Memory allocation error", MEMORY_ERROR); ents -> id = NULL; ents -> type = type; ents -> selected = NO; ents -> node_prop_list = NULL; ents -> elem_prop_list = NULL; ents -> elem_type = NULL; ents -> edge_type = NULL; ents -> tria_type = NULL; ents -> quad_type = NULL; ents -> tetra_type = NULL; ents -> pyram_type = NULL; ents -> wedge_type = NULL; ents -> hexa_type = NULL; ents -> bload_id_list = NULL; ents -> bcode_id_list = NULL; ents -> node_type = NULL; ents -> singularity_list = NULL; ents -> lcs = NULL; return(ents); } static entity_rec * create_missing_entity_id(long id, int entity_type) { entity_rec *ent = NULL; ent = create_entity_id(id, entity_type); switch(entity_type){ case VERTEX_ENTITY: vertex_list = add_item_to_list_head(vertex_list, ent); break; case CURVE_ENTITY: curve_list = add_item_to_list_head(curve_list, ent); break; case SURFACE_ENTITY: surface_list = add_item_to_list_head(surface_list, ent); break; case PATCH_ENTITY: patch_list = add_item_to_list_head(patch_list, ent); break; case SHELL_ENTITY: shell_list = add_item_to_list_head(shell_list, ent); break; case REGION_ENTITY: region_list = add_item_to_list_head(region_list, ent); break; case INTERFACE_ENTITY: interface_list = add_item_to_list_head(interface_list, ent); break; } return(ent); } /* IMPORTANT: in this function, features stored for multiple entities are copied to relevant single entities !!! */ static void process_entity(entity_rec *ent, int entity_type) { entities_rec *ents = NULL; list_rec *entities_list = NULL; list_rec *node_prop_list = NULL; list_rec *elem_prop_list = NULL; list_rec *load_id_list = NULL; list_rec *code_id_list = NULL; list_rec *singularity_list = NULL; int key; char err_msg[128]; if(ent -> selected == YES)return; switch(entity_type){ case VERTEX_ENTITY: key = VERTEX; entities_list = vertices_list; break; case CURVE_ENTITY: key = CURVE; entities_list = curves_list; break; case SURFACE_ENTITY: key = SURFACE; entities_list = surfaces_list; break; case PATCH_ENTITY: key = PATCH; entities_list = patches_list; break; case SHELL_ENTITY: key = SHELL; entities_list = shells_list; break; case REGION_ENTITY: key = REGION; entities_list = regions_list; break; case INTERFACE_ENTITY: key = INTERFACE; entities_list = interfaces_list; break; default: return; } while(entities_list != NULL){ ents = (entities_rec *)(entities_list -> item); entities_list = entities_list -> next; if(get_id(ents -> id, ent -> id) != NULL)continue; node_prop_list = ents -> node_prop_list; while(node_prop_list != NULL){ ent -> node_prop_list = add_item_to_list_head(ent -> node_prop_list, node_prop_list -> item); node_prop_list = node_prop_list -> next; } if(entity_type != VERTEX_ENTITY){ elem_prop_list = ents -> elem_prop_list; while(elem_prop_list != NULL){ ent -> elem_prop_list = add_item_to_list_head(ent -> elem_prop_list, elem_prop_list -> item); elem_prop_list = elem_prop_list -> next; } load_id_list = ents -> bload_id_list; while(load_id_list != NULL){ ent -> bload_id_list = add_item_to_list_head(ent -> bload_id_list, load_id_list -> item); load_id_list = load_id_list -> next; } code_id_list = ents -> bcode_id_list; while(code_id_list != NULL){ ent -> bcode_id_list = add_item_to_list_head(ent -> bcode_id_list, code_id_list -> item); code_id_list = code_id_list -> next; } /* do not use strcasecmp (it is not standard) */ if(ents -> elem_type != NULL && ent -> elem_type != NULL){ if(strcmp(ents -> elem_type, ent -> elem_type) != 0){ sprintf(err_msg, "Ambiguous element type specification for %s %ld", keyword[key], ent -> id); error_message(err_msg, GENERAL_ERROR); } } if(ent -> elem_type == NULL)ent -> elem_type = ents -> elem_type; switch(entity_type){ case CURVE_ENTITY: if(ents -> edge_type != NULL && ent -> edge_type != NULL){ if(strcmp(ents -> edge_type, ent -> edge_type) != 0){ sprintf(err_msg, "Ambiguous edge type specification for %s %ld", keyword[key], ent -> id); error_message(err_msg, GENERAL_ERROR); } } if(ent -> edge_type == NULL)ent -> edge_type = ents -> edge_type; break; case SURFACE_ENTITY: case PATCH_ENTITY: case SHELL_ENTITY: if(ents -> tria_type != NULL && ent -> tria_type != NULL){ if(strcmp(ents -> tria_type, ent -> tria_type) != 0){ sprintf(err_msg, "Ambiguous tria type specification for %s %ld", keyword[key], ent -> id); error_message(err_msg, GENERAL_ERROR); } } if(ents -> quad_type != NULL && ent -> quad_type != NULL){ if(strcmp(ents -> quad_type, ent -> quad_type) != 0){ sprintf(err_msg, "Ambiguous quad type specification for %s %ld", keyword[key], ent -> id); error_message(err_msg, GENERAL_ERROR); } } if(ent -> tria_type == NULL)ent -> tria_type = ents -> tria_type; if(ent -> quad_type == NULL)ent -> quad_type = ents -> quad_type; break; case REGION_ENTITY: if(ents -> tetra_type != NULL && ent -> tetra_type != NULL){ if(strcmp(ents -> tetra_type, ent -> tetra_type) != 0){ sprintf(err_msg, "Ambiguous tetra type specification for %s %ld", keyword[key], ent -> id); error_message(err_msg, GENERAL_ERROR); } } /* if(ents -> pyran_type != NULL && ent -> pyram_type != NULL){ if(strcmp(ents -> pyram_type, ent -> pyram_type) != 0){ sprintf(err_msg, "Ambiguous pyram type specification for %s %ld", keyword[key], ent -> id); error_message(err_msg, GENERAL_ERROR); } } if(ents -> wedge_type != NULL && ent -> wedge_type != NULL){ if(strcmp(ents -> wedge_type, ent -> wedge_type) != 0){ sprintf(err_msg, "Ambiguous wedge type specification for %s %ld", keyword[key], ent -> id); error_message(err_msg, GENERAL_ERROR); } } */ if(ents -> hexa_type != NULL && ent -> hexa_type != NULL){ if(strcmp(ents -> hexa_type, ent -> hexa_type) != 0){ sprintf(err_msg, "Ambiguous hexa type specification for %s %ld", keyword[key], ent -> id); error_message(err_msg, GENERAL_ERROR); } } if(ent -> tetra_type == NULL)ent -> tetra_type = ents -> tetra_type; if(ent -> pyram_type == NULL)ent -> pyram_type = ents -> pyram_type; if(ent -> wedge_type == NULL)ent -> wedge_type = ents -> wedge_type; if(ent -> hexa_type == NULL)ent -> hexa_type = ents -> hexa_type; break; case INTERFACE_ENTITY: if(ents -> edge_type != NULL && ent -> edge_type != NULL){ if(strcmp(ents -> edge_type, ent -> edge_type) != 0){ sprintf(err_msg, "Ambiguous edge type specification for %s %ld", keyword[key], ent -> id); error_message(err_msg, GENERAL_ERROR); } } if(ents -> quad_type != NULL && ent -> quad_type != NULL){ if(strcmp(ents -> quad_type, ent -> quad_type) != 0){ sprintf(err_msg, "Ambiguous quad type specification for %s %ld", keyword[key], ent -> id); error_message(err_msg, GENERAL_ERROR); } } /* if(ents -> wedge_type != NULL && ent -> wedge_type != NULL){ if(strcmp(ents -> wedge_type, ent -> wedge_type) != 0){ sprintf(err_msg, "Ambiguous wedge type specification for %s %ld", keyword[key], ent -> id); error_message(err_msg, GENERAL_ERROR); } } */ if(ents -> hexa_type != NULL && ent -> hexa_type != NULL){ if(strcmp(ents -> hexa_type, ent -> hexa_type) != 0){ sprintf(err_msg, "Ambiguous hexa type specification for %s %ld", keyword[key], ent -> id); error_message(err_msg, GENERAL_ERROR); } } if(ent -> edge_type == NULL)ent -> edge_type = ents -> edge_type; if(ent -> quad_type == NULL)ent -> quad_type = ents -> quad_type; if(ent -> wedge_type == NULL)ent -> wedge_type = ents -> wedge_type; if(ent -> hexa_type == NULL)ent -> hexa_type = ents -> hexa_type; break; default: break; } singularity_list = ents -> singularity_list; while(singularity_list != NULL){ ent -> singularity_list = add_item_to_list_head(ent -> singularity_list, singularity_list -> item); singularity_list = singularity_list -> next; } } if(ents -> lcs != NULL && ent -> lcs != NULL){ if(ents -> lcs != ent -> lcs){ sprintf(err_msg, "Ambiguous lcs specification for %s %ld", keyword[key], ent -> id); error_message(err_msg, GENERAL_ERROR); } if(ent -> lcs == NULL)ent -> lcs = ents -> lcs; } } #ifdef DEFAULT_LAST ent -> node_prop_list = reverse_list(ent -> node_prop_list); ent -> node_prop_list = reverse_list(ent -> node_prop_list); #endif ent -> selected = YES; /* mark that entity has been processed */ } static void process_entity_list(list_rec **entity_list, list_rec **entities_list, char *entity_name, int entity_type) { entity_rec *ent = NULL; entities_rec *ents = NULL; char *token = NULL, err_msg[128]; long id = -1; last_key = key; while((token = get_next_token(NULL)) != NULL){ if((key = get_token_key(token, keyword, KEY_NUM)) == ALL){ if(last_key != VERTEX && last_key != CURVE && last_key != SURFACE && last_key != PATCH && last_key != SHELL && last_key != REGION && last_key != INTERFACE){ sprintf(err_msg, "Unexpected keyword %s encountered", keyword[ALL]); error_message(err_msg, GENERAL_ERROR); } ents = create_entities(entity_type); *entities_list = add_item_to_list_head(*entities_list, (void *)ents); ents -> selected = multi_select = YES; if((token = get_next_token(NULL)) != NULL){ if((key = get_token_key(token, keyword, KEY_NUM)) != EXCEPT){ sprintf(err_msg, "Invalid or unexpected keyword \"%s\" encountered", token); error_message(err_msg, GENERAL_ERROR); } process_entities_list(ents, entity_name, entity_type); } return; } if((id = get_int_from_token(token)) <= 0){ if(last_key != PROPERTY){ sprintf(err_msg, "Invalid %s id (%ld)", entity_name, id); error_message(err_msg, GENERAL_ERROR); } } if((ent = get_entity_id(*entity_list, id)) == NULL){ ent = create_entity_id(id, entity_type); *entity_list = add_item_to_list_head(*entity_list, (void *)ent); } ent -> selected = YES; } if(id == -1){ sprintf(err_msg, "Missing %s id", entity_name); error_message(err_msg, GENERAL_ERROR); } } static void process_entities_list(entities_rec *ents, char *entity_name, int entity_type) { char *token = NULL, err_msg[128]; long id = 0, *ident = NULL; while((token = get_next_token(NULL)) != NULL){ if((id = get_int_from_token(token)) <= 0){ sprintf(err_msg, "Invalid %s id (%ld)", entity_name, id); error_message(err_msg, GENERAL_ERROR); } if((ident = get_id(id_list, id)) == NULL){ ident = create_id(id); id_list = add_item_to_list_head(id_list, (void *)ident); } ents -> id = add_item_to_list_head(ents -> id, (void *)ident); } if(id == 0){ sprintf(err_msg, "Missing %s id", entity_name); error_message(err_msg, GENERAL_ERROR); } } static void deselect_entity_list(list_rec *entity_list) { entity_rec *ent = NULL; while(entity_list != NULL){ ent = (entity_rec *)(entity_list -> item); entity_list = entity_list -> next; ent -> selected = NO; } } static void deselect_entities_list(list_rec *entities_list) { entities_rec *ents = NULL; while(entities_list != NULL){ ents = (entities_rec *)(entities_list -> item); entities_list = entities_list -> next; if(ents -> selected == NO)return; ents -> selected = NO; } } static void deselect_interface_1D_list(void) { list_rec *iface_list =interface_1D_list; interface_1D_rec *interface_1D = NULL; while(iface_list != NULL){ interface_1D = (interface_1D_rec *)(iface_list -> item); iface_list = iface_list -> next; interface_1D -> selected = NO; } } static void reverse_node_elem_entity_list(list_rec *entity_list) { entity_rec *ent = NULL; while(entity_list != NULL){ ent = (entity_rec *)(entity_list -> item); entity_list = entity_list -> next; ent -> node_prop_list = reverse_list(ent -> node_prop_list); ent -> elem_prop_list = reverse_list(ent -> elem_prop_list); } } static void apply_node_properties(char *string) { if(entity_select == YES){ if(vertex_select == YES)apply_node_properties_entity_list(vertex_list, string); if(curve_select == YES)apply_node_properties_entity_list(curve_list, string); if(surface_select == YES)apply_node_properties_entity_list(surface_list, string); if(patch_select == YES)apply_node_properties_entity_list(patch_list, string); if(shell_select == YES)apply_node_properties_entity_list(shell_list, string); if(region_select == YES)apply_node_properties_entity_list(region_list, string); /* if(interface_select == YES)apply_node_properties_entity_list(interface_list, string); */ if(multi_select == YES){ if(vertex_select == YES)apply_node_properties_entities_list(vertices_list, string); if(curve_select == YES)apply_node_properties_entities_list(curves_list, string); if(surface_select == YES)apply_node_properties_entities_list(surfaces_list, string); if(patch_select == YES)apply_node_properties_entities_list(patches_list, string); if(shell_select == YES)apply_node_properties_entities_list(shells_list, string); if(region_select == YES)apply_node_properties_entities_list(regions_list, string); /* if(interface_select == YES)apply_node_properties_entities_list(interfaces_list, string); */ } } if(property_select == YES)apply_node_properties_entity_list(property_list, string); } static void apply_node_properties_entity_list(list_rec *entity_list, char *string) { entity_rec *ent = NULL; void *item = (void *)string; while(entity_list != NULL){ ent = (entity_rec *)(entity_list -> item); entity_list = entity_list -> next; if(ent -> selected == NO)continue; ent -> node_prop_list = add_item_to_list_head(ent -> node_prop_list, item); } } static void apply_node_properties_entities_list(list_rec *entities_list, char *string) { entities_rec *ents = NULL; void *item = (void *)string; while(entities_list != NULL){ ents = (entities_rec *)(entities_list -> item); entities_list = entities_list -> next; if(ents -> selected == NO)return; ents -> node_prop_list = add_item_to_list_head(ents -> node_prop_list, item); } } static void apply_elem_properties(char *string) { if(entity_select == YES){ /* if(vertex_select == YES)apply_elem_properties_entity_list(vertex_list, string); */ if(curve_select == YES)apply_elem_properties_entity_list(curve_list, string); if(surface_select == YES)apply_elem_properties_entity_list(surface_list, string); if(patch_select == YES)apply_elem_properties_entity_list(patch_list, string); if(shell_select == YES)apply_elem_properties_entity_list(shell_list, string); if(region_select == YES)apply_elem_properties_entity_list(region_list, string); if(interface_select == YES)apply_elem_properties_entity_list(interface_list, string); if(multi_select == YES){ /* if(vertex_select == YES)apply_elem_properties_entities_list(vertices_list, string); */ if(curve_select == YES)apply_elem_properties_entities_list(curves_list, string); if(surface_select == YES)apply_elem_properties_entities_list(surfaces_list, string); if(patch_select == YES)apply_elem_properties_entities_list(patches_list, string); if(shell_select == YES)apply_elem_properties_entities_list(shells_list, string); if(region_select == YES)apply_elem_properties_entities_list(regions_list, string); if(interface_select == YES)apply_elem_properties_entities_list(interfaces_list, string); } } if(property_select == YES)apply_elem_properties_entity_list(property_list, string); if(interface_1D_select == YES)apply_elem_properties_interface_1D_list(string); } static void apply_elem_properties_entity_list(list_rec *entity_list, char *string) { entity_rec *ent = NULL; void *item = (void *)string; while(entity_list != NULL){ ent = (entity_rec *)(entity_list -> item); entity_list = entity_list -> next; if(ent -> selected == NO)continue; ent -> elem_prop_list = add_item_to_list_head(ent -> elem_prop_list, item); } } static void apply_elem_properties_entities_list(list_rec *entities_list, char *string) { entities_rec *ents = NULL; void *item = (void *)string; while(entities_list != NULL){ ents = (entities_rec *)(entities_list -> item); entities_list = entities_list -> next; if(ents -> selected == NO)return; ents -> elem_prop_list = add_item_to_list_head(ents -> elem_prop_list, item); } } static void apply_elem_properties_interface_1D_list(char *string) { list_rec *iface_list =interface_1D_list; interface_1D_rec *interface_1D = NULL; void *item = (void *)string; while(iface_list != NULL){ interface_1D = (interface_1D_rec *)(iface_list -> item); iface_list = iface_list -> next; if(interface_1D -> selected == NO)continue; interface_1D -> elem_prop_list = add_item_to_list_head(interface_1D -> elem_prop_list, item); } } static void apply_node_type(char *string) { if(entity_select == YES){ if(vertex_select == YES)apply_node_type_entity_list(vertex_list, string, keyword[VERTEX]); if(curve_select == YES)apply_node_type_entity_list(curve_list, string, keyword[CURVE]); if(surface_select == YES)apply_node_type_entity_list(surface_list, string, keyword[SURFACE]); if(patch_select == YES)apply_node_type_entity_list(patch_list, string, keyword[PATCH]); if(shell_select == YES)apply_node_type_entity_list(shell_list, string, keyword[SHELL]); if(region_select == YES)apply_node_type_entity_list(region_list, string, keyword[REGION]); /* if(interface_select == YES)apply_node_type_entity_list(interface_list, string, keyword[INTERFACE]); */ if(multi_select == YES){ if(vertex_select == YES)apply_node_type_entities_list(vertices_list, string, keyword[VERTEX]); if(curve_select == YES)apply_node_type_entities_list(curves_list, string, keyword[CURVE]); if(surface_select == YES)apply_node_type_entities_list(surfaces_list, string, keyword[SURFACE]); if(patch_select == YES)apply_node_type_entities_list(patches_list, string, keyword[PATCH]); if(shell_select == YES)apply_node_type_entities_list(shells_list, string, keyword[SHELL]); if(region_select == YES)apply_node_type_entities_list(regions_list, string, keyword[REGION]); /* if(interface_select == YES)apply_node_type_entities_list(interfaces_list, string, keyword[INTERFACE]); */ } } } static void apply_node_type_entity_list(list_rec *entity_list, char *string, char *entity_name) { entity_rec *ent = NULL; char err_msg[128]; while(entity_list != NULL){ ent = (entity_rec *)(entity_list -> item); entity_list = entity_list -> next; if(ent -> selected == NO)continue; if(ent -> node_type != NULL){ sprintf(err_msg, "Duplication of node type specification for %s %ld", entity_name, ent -> id); error_message(err_msg, GENERAL_ERROR); } ent -> node_type = string; } } static void apply_node_type_entities_list(list_rec *entities_list, char *string, char *entity_name) { entities_rec *ents = NULL; while(entities_list != NULL){ ents = (entities_rec *)(entities_list -> item); entities_list = entities_list -> next; if(ents -> selected == NO)return; ents -> node_type = string; } } static void apply_elem_type(char *string) { if(entity_select == YES){ /* if(vertex_select == YES)apply_elem_type_entity_list(vertex_list, string, keyword[VERTEX]); */ if(curve_select == YES)apply_elem_type_entity_list(curve_list, string, keyword[CURVE]); if(surface_select == YES)apply_elem_type_entity_list(surface_list, string, keyword[SURFACE]); if(patch_select == YES)apply_elem_type_entity_list(patch_list, string, keyword[PATCH]); if(shell_select == YES)apply_elem_type_entity_list(shell_list, string, keyword[SHELL]); if(region_select == YES)apply_elem_type_entity_list(region_list, string, keyword[REGION]); if(interface_select == YES)apply_elem_type_entity_list(interface_list, string, keyword[INTERFACE]); if(multi_select == YES){ /* if(vertex_select == YES)apply_elem_type_entities_list(vertices_list, string, keyword[VERTEX]); */ if(curve_select == YES)apply_elem_type_entities_list(curves_list, string, keyword[CURVE]); if(surface_select == YES)apply_elem_type_entities_list(surfaces_list, string, keyword[SURFACE]); if(patch_select == YES)apply_elem_type_entities_list(patches_list, string, keyword[PATCH]); if(shell_select == YES)apply_elem_type_entities_list(shells_list, string, keyword[SHELL]); if(region_select == YES)apply_elem_type_entities_list(regions_list, string, keyword[REGION]); if(interface_select == YES)apply_elem_type_entities_list(interfaces_list, string, keyword[INTERFACE]); } } } static void apply_elem_type_entity_list(list_rec *entity_list, char *string, char *entity_name) { entity_rec *ent = NULL; char err_msg[128]; while(entity_list != NULL){ ent = (entity_rec *)(entity_list -> item); entity_list = entity_list -> next; if(ent -> selected == NO)continue; switch(key){ case ELEMTYPE: if(ent -> elem_type != NULL){ sprintf(err_msg, "Duplication of element type specification for %s %ld", entity_name, ent -> id); error_message(err_msg, GENERAL_ERROR); } ent -> elem_type = string; break; case EDGETYPE: if(ent -> edge_type != NULL){ sprintf(err_msg, "Duplication of edge type specification for %s %ld", entity_name, ent -> id); error_message(err_msg, GENERAL_ERROR); } ent -> edge_type = string; break; case TRIATYPE: if(ent -> tria_type != NULL){ sprintf(err_msg, "Duplication of tria type specification for %s %ld", entity_name, ent -> id); error_message(err_msg, GENERAL_ERROR); } ent -> tria_type = string; break; case QUADTYPE: if(ent -> quad_type != NULL){ sprintf(err_msg, "Duplication of quad type specification for %s %ld", entity_name, ent -> id); error_message(err_msg, GENERAL_ERROR); } ent -> quad_type = string; break; case TETRATYPE: if(ent -> tetra_type != NULL){ sprintf(err_msg, "Duplication of tetra type specification for %s %ld", entity_name, ent -> id); error_message(err_msg, GENERAL_ERROR); } ent -> tetra_type = string; break; case HEXATYPE: if(ent -> hexa_type != NULL){ sprintf(err_msg, "Duplication of hexa type specification for %s %ld", entity_name, ent -> id); error_message(err_msg, GENERAL_ERROR); } ent -> hexa_type = string; /* pyrams and wedges are treated as degenerated hexas */ ent -> pyram_type = string; ent -> wedge_type = string; break; default: break; } } } static void apply_elem_type_entities_list(list_rec *entities_list, char *string, char *entity_name) { entities_rec *ents = NULL; while(entities_list != NULL){ ents = (entities_rec *)(entities_list -> item); entities_list = entities_list -> next; if(ents -> selected == NO)return; switch(key){ case ELEMTYPE: ents -> elem_type = string; break; case EDGETYPE: ents -> edge_type = string; break; case TRIATYPE: ents -> tria_type = string; break; case QUADTYPE: ents -> quad_type = string; break; case TETRATYPE: ents -> tetra_type = string; break; case HEXATYPE: ents -> hexa_type = string; /* pyrams and wedges are treated as degenerated hexas */ ents -> pyram_type = string; ents -> wedge_type = string; break; default: break; } } } static void apply_elem_bload(long *ident) { if(entity_select == YES){ /* if(vertex_select == YES)apply_elem_bload_entity_list(vertex_list, ident); */ if(curve_select == YES)apply_elem_bload_entity_list(curve_list, ident); if(surface_select == YES)apply_elem_bload_entity_list(surface_list, ident); if(patch_select == YES)apply_elem_bload_entity_list(patch_list, ident); if(shell_select == YES)apply_elem_bload_entity_list(shell_list, ident); if(region_select == YES)apply_elem_bload_entity_list(region_list, ident); /* if(interface_select == YES)apply_elem_bload_entity_list(interface_list, ident); */ if(multi_select == YES){ /* if(vertex_select == YES)apply_elem_bload_entities_list(vertices_list, ident); */ if(curve_select == YES)apply_elem_bload_entities_list(curves_list, ident); if(surface_select == YES)apply_elem_bload_entities_list(surfaces_list, ident); if(patch_select == YES)apply_elem_bload_entities_list(patches_list, ident); if(shell_select == YES)apply_elem_bload_entities_list(shells_list, ident); if(region_select == YES)apply_elem_bload_entities_list(regions_list, ident); /* if(interface_select == YES)apply_elem_bload_entities_list(interfaces_list, ident); */ } } } static void apply_elem_bload_entity_list(list_rec *entity_list, long *ident) { entity_rec *ent = NULL; void *item = (void *)ident; while(entity_list != NULL){ ent = (entity_rec *)(entity_list -> item); entity_list = entity_list -> next; if(ent -> selected == NO)continue; ent -> bload_id_list = add_item_to_list_head(ent -> bload_id_list, item); } } static void apply_elem_bload_entities_list(list_rec *entities_list, long *ident) { entities_rec *ents = NULL; void *item = (void *)ident; while(entities_list != NULL){ ents = (entities_rec *)(entities_list -> item); entities_list = entities_list -> next; if(ents -> selected == NO)continue; ents -> bload_id_list = add_item_to_list_head(ents -> bload_id_list, item); } } static void apply_elem_bcode(long *ident) { if(entity_select == YES){ /* if(vertex_select == YES)apply_elem_bcode_entity_list(vertex_list, ident); */ if(curve_select == YES)apply_elem_bcode_entity_list(curve_list, ident); if(surface_select == YES)apply_elem_bcode_entity_list(surface_list, ident); if(patch_select == YES)apply_elem_bcode_entity_list(patch_list, ident); if(shell_select == YES)apply_elem_bcode_entity_list(shell_list, ident); if(region_select == YES)apply_elem_bcode_entity_list(region_list, ident); /* if(interface_select == YES)apply_elem_bcode_entity_list(interface_list, ident); */ if(multi_select == YES){ /* if(vertex_select == YES)apply_elem_bcode_entities_list(vertices_list, ident); */ if(curve_select == YES)apply_elem_bcode_entities_list(curves_list, ident); if(surface_select == YES)apply_elem_bcode_entities_list(surfaces_list, ident); if(patch_select == YES)apply_elem_bcode_entities_list(patches_list, ident); if(shell_select == YES)apply_elem_bcode_entities_list(shells_list, ident); if(region_select == YES)apply_elem_bcode_entities_list(regions_list, ident); /* if(interface_select == YES)apply_elem_bcode_entities_list(interfaces_list, ident); */ } } } static void apply_elem_bcode_entity_list(list_rec *entity_list, long *ident) { entity_rec *ent = NULL; void *item = (void *)ident; while(entity_list != NULL){ ent = (entity_rec *)(entity_list -> item); entity_list = entity_list -> next; if(ent -> selected == NO)continue; ent -> bcode_id_list = add_item_to_list_head(ent -> bcode_id_list, item); } } static void apply_elem_bcode_entities_list(list_rec *entities_list, long *ident) { entities_rec *ents = NULL; void *item = (void *)ident; while(entities_list != NULL){ ents = (entities_rec *)(entities_list -> item); entities_list = entities_list -> next; if(ents -> selected == NO)continue; ents -> bcode_id_list = add_item_to_list_head(ents -> bcode_id_list, item); } } static void apply_singularity(singularity_rec *singularity) { if(entity_select == YES){ /* if(vertex_select == YES)apply_singularity_entity_list(vertex_list, singularity); */ if(curve_select == YES)apply_singularity_entity_list(curve_list, singularity); if(surface_select == YES)apply_singularity_entity_list(surface_list, singularity); if(patch_select == YES)apply_singularity_entity_list(patch_list, singularity); if(shell_select == YES)apply_singularity_entity_list(shell_list, singularity); if(region_select == YES)apply_singularity_entity_list(region_list, singularity); /* if(interface_select == YES)apply_singularity_entity_list(interface_list, singularity); */ if(multi_select == YES){ /* if(vertex_select == YES)apply_singularity_entities_list(vertices_list, singularity); */ if(curve_select == YES)apply_singularity_entities_list(curves_list, singularity); if(surface_select == YES)apply_singularity_entities_list(surfaces_list, singularity); if(patch_select == YES)apply_singularity_entities_list(patches_list, singularity); if(shell_select == YES)apply_singularity_entities_list(shells_list, singularity); if(region_select == YES)apply_singularity_entities_list(regions_list, singularity); /* if(interface_select == YES)apply_singularity_entities_list(interfaces_list, singularity); */ } } } static void apply_singularity_entity_list(list_rec *entity_list, singularity_rec *singularity) { entity_rec *ent = NULL; void *item = (void *)singularity; while(entity_list != NULL){ ent = (entity_rec *)(entity_list -> item); entity_list = entity_list -> next; if(ent -> selected == NO)continue; ent -> singularity_list = add_item_to_list_head(ent -> singularity_list, item); } } static void apply_singularity_entities_list(list_rec *entities_list, singularity_rec *singularity) { entities_rec *ents = NULL; void *item = (void *)singularity; while(entities_list != NULL){ ents = (entities_rec *)(entities_list -> item); entities_list = entities_list -> next; if(ents -> selected == NO)continue; ents -> singularity_list = add_item_to_list_head(ents -> singularity_list, item); } } static void apply_lcs(lcs_rec *lcs) { if(entity_select == YES){ if(vertex_select == YES)apply_lcs_entity_list(vertex_list, lcs); if(curve_select == YES)apply_lcs_entity_list(curve_list, lcs); if(surface_select == YES)apply_lcs_entity_list(surface_list, lcs); if(patch_select == YES)apply_lcs_entity_list(patch_list, lcs); if(shell_select == YES)apply_lcs_entity_list(shell_list, lcs); /* if(region_select == YES)apply_lcs_entity_list(region_list, lcs); */ /* if(interface_select == YES)apply_lcs_entity_list(interface_list, lcs); */ if(multi_select == YES){ if(vertex_select == YES)apply_lcs_entities_list(vertices_list, lcs); if(curve_select == YES)apply_lcs_entities_list(curves_list, lcs); if(surface_select == YES)apply_lcs_entities_list(surfaces_list, lcs); if(patch_select == YES)apply_lcs_entities_list(patches_list, lcs); if(shell_select == YES)apply_lcs_entities_list(shells_list, lcs); /* if(region_select == YES)apply_lcs_entities_list(regions_list, lcs); */ /* if(interface_select == YES)apply_lcs_entities_list(interfaces_list, lcs); */ } } } static void apply_lcs_entity_list(list_rec *entity_list, lcs_rec *lcs) { entity_rec *ent = NULL; while(entity_list != NULL){ ent = (entity_rec *)(entity_list -> item); entity_list = entity_list -> next; if(ent -> selected == NO)continue; ent -> lcs = lcs; } } static void apply_lcs_entities_list(list_rec *entities_list, lcs_rec *lcs) { entities_rec *ents = NULL; while(entities_list != NULL){ ents = (entities_rec *)(entities_list -> item); entities_list = entities_list -> next; if(ents -> selected == NO)continue; ents -> lcs = lcs; } } /* note: in linear case, edge flag is processed only if there is boundary curve */ static logic get_linear_edge_flag(long node1_id, long node2_id, long curve_id) { entity_rec *ent1 = NULL, *ent2 = NULL; long nd1_id, nd2_id, nd_id, *ident = NULL; if(curve_id == 0)return(NO); nd1_id = con_node1[node1_id - 1]; if(nd1_id == 0){ /* node1 is not yet processed curve node */ con_node1[node1_id - 1] = node2_id; /* update con nodes of node2 unless node2 is vertex */ nd_id = con_node1[node2_id - 1]; if(nd_id == 0) /* node2 is not yet processed curve node */ con_node1[node2_id - 1] = node1_id; else{ if(nd_id> 0){ /* node2 is at least once processed curve node */ if(nd_id != node1_id)con_node2[node2_id - 1] = node1_id; } } return(NO); } if(nd1_id> 0){ /* node1 is at least once processed curve node */ if(nd1_id == node2_id)return(YES); nd_id = con_node2[node1_id - 1]; if(nd_id == 0){ con_node2[node1_id - 1] = node2_id; /* update con nodes of node2 unless node2 is vertex */ nd_id = con_node1[node2_id - 1]; if(nd_id == 0) /* node2 is not yet processed curve node */ con_node1[node2_id - 1] = node1_id; else{ if(nd_id> 0){ /* node2 is at least once processed curve node */ if(nd_id != node1_id)con_node2[node2_id - 1] = node1_id; } } return(NO); } if(nd_id> 0){ /* node2 is twice processed curve node */ if(nd_id != node2_id) error_message("Unexpected situation", GENERAL_ERROR); } return(YES); } nd2_id = con_node1[node2_id - 1]; if(nd2_id == 0){ /* node2 is not yet processed curve node */ con_node1[node2_id - 1] = node1_id; /* update con nodes of node1 unless node2 is vertex */ nd_id = con_node1[node1_id - 1]; if(nd_id == 0) /* node1 is not yet processed curve node */ con_node1[node1_id - 1] = node2_id; else{ if(nd_id> 0){ /* node1 is at least once processed curve node */ if(nd_id != node2_id)con_node2[node1_id - 1] = node2_id; } } return(NO); } if(nd2_id> 0){ /* node2 is at least once processed curve node */ if(nd2_id == node1_id)return(YES); nd_id = con_node2[node2_id - 1]; if(nd_id == 0){ con_node2[node2_id - 1] = node1_id; /* update con nodes of node1 unless node1 is vertex */ nd_id = con_node1[node1_id - 1]; if(nd_id == 0) /* node1 is not yet processed curve node */ con_node1[node1_id - 1] = node2_id; else{ if(nd_id> 0){ /* node1 is at least once processed curve node */ if(nd_id != node2_id)con_node2[node1_id - 1] = node2_id; } } return(NO); } if(nd_id> 0){ /* node1 is twice processed curve node */ if(nd_id != node1_id) error_message("Unexpected situation", GENERAL_ERROR); } return(YES); } /* node1 as well as node2 are vertices; use list of ids of curves connected to the vertex; these lists are available only if both nodes are vertices **/ ent1 = get_entity_id(vertex_list, -nd1_id); ent2 = get_entity_id(vertex_list, -nd2_id); if((ident = get_id(ent1 -> curve_id_list, curve_id)) != NULL)return(YES); if((ident = get_id(ent2 -> curve_id_list, curve_id)) != NULL)error_message("Unexpected situation", GENERAL_ERROR); ident = create_id(curve_id); id_list = add_item_to_list_head(id_list, (void *)ident); ent1 -> curve_id_list = add_item_to_list_head(ent1 -> curve_id_list, (void *)ident); ent2 -> curve_id_list = add_item_to_list_head(ent2 -> curve_id_list, (void *)ident); return(NO); } /* note: in quadratic case, edge flag is processed irrespectably whether there is boundary curve */ static logic get_quadratic_edge_flag(long midnode_id) { if(node_flag[midnode_id - 1] == 0){ node_flag[midnode_id - 1] = 1; return(NO); } return(YES); } static void destroy_entity_list(list_rec *entity_list) { entity_rec *ent = NULL; while(entity_list != NULL){ ent = (entity_rec *)(entity_list -> item); entity_list = entity_list -> next; if(ent -> node_prop_list != NULL)ent -> node_prop_list = destroy_list(ent -> node_prop_list); if(ent -> elem_prop_list != NULL)ent -> elem_prop_list = destroy_list(ent -> elem_prop_list); if(ent -> bload_id_list != NULL)ent -> bload_id_list = destroy_list(ent -> bload_id_list); if(ent -> bcode_id_list != NULL)ent -> bcode_id_list = destroy_list(ent -> bcode_id_list); if(ent -> curve_id_list != NULL)ent -> curve_id_list = destroy_list(ent -> curve_id_list); if(ent -> singularity_list != NULL)ent -> singularity_list = destroy_list(ent -> singularity_list); if(ent -> dirs != NULL){ free(ent -> dirs); ent -> dirs = NULL; } } } static void destroy_entities_list(list_rec *entities_list) { entities_rec *ents = NULL; while(entities_list != NULL){ ents = (entities_rec *)(entities_list -> item); entities_list = entities_list -> next; if(ents -> id != NULL)ents -> id = destroy_list(ents -> id); if(ents -> node_prop_list != NULL)ents -> node_prop_list = destroy_list(ents -> node_prop_list); if(ents -> elem_prop_list != NULL)ents -> elem_prop_list = destroy_list(ents -> elem_prop_list); if(ents -> bload_id_list != NULL)ents -> bload_id_list = destroy_list(ents -> bload_id_list); if(ents -> bcode_id_list != NULL)ents -> bcode_id_list = destroy_list(ents -> bcode_id_list); if(ents -> singularity_list != NULL)ents -> singularity_list = destroy_list(ents -> singularity_list); } } static void destroy_interface_1D_list(void) { list_rec *iface_list =interface_1D_list; interface_1D_rec *interface_1D = NULL; while(iface_list != NULL){ interface_1D = (interface_1D_rec *)(iface_list -> item); iface_list = iface_list -> next; if(interface_1D -> elem_prop_list != NULL)interface_1D -> elem_prop_list = destroy_list(interface_1D -> elem_prop_list); } } static void check_entity_list(list_rec *entity_list, char *entity_name) { entity_rec *ent = NULL; while(entity_list != NULL){ ent = (entity_rec *)(entity_list -> item); entity_list = entity_list -> next; if(ent -> on_output == NO){ fprintf(stderr, "Warning: %s %ld referenced in ctrl file is not present in t3d output file\n", entity_name, ent -> id); warning = YES; } } } static singularity_rec * create_singularity(long node_id, double x, double y, double z, double radius) { singularity_rec *singularity = NULL; singularity = (singularity_rec *)malloc(sizeof(singularity_rec)); if(singularity == NULL)error_message("Memory allocation error", MEMORY_ERROR); singularity -> node_id = node_id; singularity -> center.x = x; singularity -> center.y = y; singularity -> center.z = z; singularity -> radius = radius; singularity -> elems = 0; return(singularity); } static logic check_inside_singularity(entity_rec *entity, int nodes, long *node_array) { list_rec *sing_list = entity -> singularity_list; singularity_rec *singularity = NULL; double dx, dy, dz, dist2, radius, radius2; node_rec *fe_node = NULL; logic inside = NO; int j; while(sing_list != NULL){ singularity = (singularity_rec *)(sing_list -> item); sing_list = sing_list -> next; radius = singularity -> radius; radius2 = radius * radius; #ifdef ALL_NODES_INSIDE inside = YES; #endif for(j = 0; j < nodes; j++){ fe_node = &(fe_nodes[node_array[j] - 1]); dx = fe_node -> x - singularity -> center.x; dy = fe_node -> y - singularity -> center.y; dz = fe_node -> z - singularity -> center.z; dist2 = dx * dx + dy * dy + dz * dz; #ifdef ALL_NODES_INSIDE if(dist2> radius2){ inside = NO; break; } #else if(dist2 < radius * radius){ singularity -> elems++; return(YES); } #endif } if(inside == YES){ singularity -> elems++; return(YES); } } return(NO); } static logic write_fictitious_csect(char *string, int csect, char *entity_name, long entity_id, FILE *file) { int length; char *str = string, ch, *ch_ptr = NULL; char err_msg[256], out_err_msg[256]; int j, csect_id; length = (int)strlen(str); /* replace cross section id by fictitious cross section id */ for(j = 0; j < length - 9; j++, str++){ if(strncasecmp(str, "crosssect", 9) == 0){ str += 9; ch_ptr = str; ch = *ch_ptr; /* store original character */ *str++ = '0円'; while(*str == ' ' || *str == '\t')str++; sscanf(str, "%d", &csect_id); while(*str != ' ' && *str != '\t' && *string != '0円' && *string != '\n')str++; if(csect_id <= 0 || csect_id> csect){ sprintf(err_msg, "Invalid cross section id (%d) for elements on %s %ld", csect_id, entity_name, entity_id); error_message(err_msg, GENERAL_ERROR); } if(fprintf(file, "%s %d%s", string, csect_id + csect, str) < 0) error_message(out_err_msg, FILE_WRITE_ERROR); /* OOFEM elem record */ *ch_ptr = ch; /* restore original character */ return(YES); } } return(NO); } static interface_1D_rec * create_interface_1D(entity_rec *master, entity_rec *slave, int type, double x, double y, double z) { interface_1D_rec *interface_1D = NULL; double size; interface_1D = (interface_1D_rec *)malloc(sizeof(interface_1D_rec)); if(interface_1D == NULL)error_message("Memory allocation error", MEMORY_ERROR); interface_1D -> type = type; interface_1D -> master = master; interface_1D -> slave = slave; if(type / 2 * 2 == type){ /* 0, 2, 4 */ size = sqrt(x * x + y * y + z * z); if(fabs(size) < 1.0e-5)error_message("Zero interface_1D vector", GENERAL_ERROR); interface_1D -> vector.x = x; interface_1D -> vector.y = y; interface_1D -> vector.z = z; } interface_1D -> elem_prop_list = NULL; interface_1D -> selected = NO; return(interface_1D); } static lcs_rec * create_lcs(int entity_type, long entity_id, int lcs_x, int lcs_y, double x, double y, double z) { lcs_rec *lcs = NULL; lcs = (lcs_rec *)malloc(sizeof(lcs_rec)); if(lcs == NULL)error_message("Memory allocation error", MEMORY_ERROR); lcs -> entity_type = entity_type; lcs -> entity_id = entity_id; lcs -> lcs_x = lcs_x; lcs -> lcs_y = lcs_y; lcs -> ref_vector.x = x; lcs -> ref_vector.y = y; lcs -> ref_vector.z = z; return(lcs); } static char * store_string(char *string) { char *str = NULL; str = (char *)malloc((int)strlen(string) + 1); if(str == NULL)error_message("Memory allocation error", MEMORY_ERROR); strcpy(str,string); return(str); } static void exit_error_message(char *message, int exit_code, int line) { fprintf(stderr, "\nt3d2oofem: line %d\n%s\n", line, message); if(exit_code == FILE_READ_ERROR){ fprintf(stderr, "%s\n", line_buffer); } fprintf(stderr, "\n"); exit(exit_code); }

AltStyle によって変換されたページ (->オリジナル) /