def nastran_to_abaqus(nastran_model, abqaqus_filename_out): """ Handles CTRIA3, CQUAD4 TODO: doesn't renumber TDOO: completely ignores properties TODO: assuming constant property """ log = nastran_model.log model = Abaqus(log=log, debug=True) node_sets = None element_sets = None solid_sections = None ctria3s = [] cquad4s = [] for eid, elem in iteritems(nastran_model.elements): if elem.type == 'CTRIA3': node_ids = elem.nodes ctria3 = [eid] + node_ids ctria3s.append(ctria3) elif elem.type == 'CQUAD4': node_ids = elem.nodes cquad4 = [eid] + node_ids cquad4s.append(cquad4) else: pass #log.warning('skipping:\n%s' % elem) element_types = { 'cpe3' : ctria3s, 'cpe4' : cquad4s, } name = 'model' icd_transform, icp_transform, xyz_cp, nid_cp_cd = nastran_model.get_displacement_index_xyz_cp_cd( fdtype='float64', sort_ids=True) nids = nid_cp_cd[:, 0] xyz_cid0 = nastran_model.transform_xyzcp_to_xyz_cid( xyz_cp, nids, icp_transform, cid=0, in_place=False) nodes = xyz_cid0 part = Part(name, nids, nodes, element_types, node_sets, element_sets, solid_sections, log) model.parts[name] = part model.write(abqaqus_filename_out) return model
def nastran_to_abaqus_filename(bdf_filename: str, abaqus_inp_filename: str): nastran_model = read_bdf(bdf_filename) log = nastran_model.log model = Abaqus(log=None, debug=True) name = 'model' nids = [] nodes = [] for nid, node in nastran_model.nodes.items(): xyz = node.get_position() nids.append(nid) nodes.append(xyz) nodes = np.array(nodes, dtype='float32') node_sets = {} element_sets = {} ctria3s = [] cquad4s = [] ctetra4s = [] ctetra10s = [] chexa8s = [] chexa20s = [] element_types = { 'cpe3': ctria3s, # CTRIA3 'cpe4': cquad4s, 'c3d10h': ctetra10s, 'c3d4r': ctetra4s, 'c3d8r': chexa8s, 'c3d20r': chexa20s, } pid_to_name_map = {} element_sets_temp = {} shell_sections = [] for pid, prop in nastran_model.properties.items(): pid_to_name_map[pid] = f'{prop.type}_{pid}' # PSHELL_20 element_sets_temp[pid] = [] # 20 if prop.type == 'PSHELL': mid = prop.mid1 material_name = f'{prop.mid1_ref.type}_{mid}' thickness = prop.t shell_section = ShellSection(material_name, thickness, log) shell_sections.append(shell_section) elif prop.type == 'PSOLID': material_name = f'{prop.mid_ref.type}_{mid}' elset = None thickness = None solid_section = SolidSection(material_name, elset, thickness, log) solid_sections.append(solid_section) else: print(prop) #elif prop.type == 'PSHELL': for eid, elem in nastran_model.elements.items(): pid = elem.pid nidsi = elem.nodes if elem.type in ['CTRIA3']: ctria3s.append([eid] + nidsi) elif elem.type in ['CQUAD4']: cquad4s.append([eid] + nidsi) elif elem.type in ['CTETRA4']: ctetra4s.append([eid] + nidsi) elif elem.type in ['CTETRA10']: ctetra10s.append([eid] + nidsi) elif elem.type in ['CHEXA8']: chexa8s.append([eid] + nidsi) elif elem.type in ['CHEXA20']: chexa20s.append([eid] + nidsi) else: print(elem) element_sets_temp[pid].append(eid) for pid, pid_str in pid_to_name_map.items(): eids = element_sets_temp[pid] element_sets[pid_str] = np.array(eids, dtype='int32') del pid_to_name_map del element_sets_temp cloads = _process_constraints(nastran_model, node_sets) solid_sections = [] shell_sections = [] part = Part(name, nids, nodes, element_types, node_sets, element_sets, solid_sections, shell_sections, log=log) model.parts = { 'model': part, } for mid, mat in nastran_model.materials.items(): name = f'{mat.type}_mid{mid}' density = mat.rho if mat.rho else 0.0 sections = { 'elastic': 'cat', } material = Material(name, sections, density=density, is_elastic=True, ndepvars=None, ndelete=None) model.materials[name] = material name = 'static_step' boundaries = [] outputs = [] static_step = Step(name, boundaries, outputs, cloads=cloads, is_nlgeom=False) model.steps = [static_step] model.write(abaqus_inp_filename, is_2d=False)