Ejemplo n.º 1
0
def exe(entities, params):
	part_duplicity = {}

	t1 = base.CheckReport('Wrong master group name')
	t2 = base.CheckReport('Wrong slave group name')
	t3 = base.CheckReport('Wrong part tied name')
	t4 = base.CheckReport('Missing space for tied name')
	t5 = base.CheckReport('Assigning of parts is duplicated')

	t1.has_fix = True
	t2.has_fix = True
	t3.has_fix = True
	t4.has_fix = True
	t5.has_fix = False

	for tied_ent in entities:

		tied = tied_cls(tied_ent._id)

		if tied.tied_flag == True:
			tied.realize(params['Include prefix'])

			if  tied.tied_part_ent in part_duplicity:
				part_duplicity[tied.tied_part_ent] = part_duplicity[tied.tied_part_ent] + 1
			else:
				part_duplicity[tied.tied_part_ent] = 0

			if not tied.tied.startswith(' '):
				t4.add_issue(entities = [tied], status = 'Error',
					description = 'Missing space for tied name',
					entity_name = tied.tied_name,
					suggest_name = ' ' + tied.tied_name)

			if tied.group_master_name != tied.suggest_group_master_name:
				t1.add_issue(entities = [tied.group_ent_master], status = 'Error',
					description = 'Wrong master group name',
					entity_name = tied.group_master_name,
					suggest_name = tied.suggest_group_master_name)

			if tied.group_slave_name != tied.suggest_group_slave_name:
				t2.add_issue(entities = [tied.group_ent_slave], status = 'Error',
					description = 'Wrong slave group name',
					entity_name = tied.group_slave_name,
					suggest_name = tied.suggest_group_slave_name)

			if tied.tied_part_name != tied.suggest_part_tied_name:
				t3.add_issue(entities = [tied.tied_part_ent], status = 'Error',
					description = 'Wrong tied group name',
					entity_name = tied.tied_part_name,
					suggest_name = tied.suggest_part_tied_name)

	for var in part_duplicity:
		if part_duplicity[var] >= 1:
		  t5.add_issue(entities = [var], status = 'Error',
			  description = 'Assigning of parts is duplicated ' + str(part_duplicity[var]) + 'x')

	return [t5, t1, t2, t2, t4]
def exe(entities, params):
    t = base.CheckReport('Element check' + params['type_check'])
    t.has_fix = True
    if entities:
        if not (type(entities) == list):
            entities = [entities]
        if type(entities) == list:
            for entity in entities:
                entity_full = entity_cls(entity._id, params['type_check'])
                entity_full.check(params)
                ent = [
                    base.GetEntity(constants.ABAQUS, params['type_check'],
                                   entity._id)
                ]
                status, status_lenght = entity_full.check(params)
                descriptions = ''
                if status != '':
                    descriptions = status
                    t.add_issue(entities=ent,
                                status="Warning",
                                description=descriptions)
                if status_lenght != '':
                    descriptions = status_lenght
                    t.add_issue(entities=ent,
                                status="Warning",
                                description=descriptions)

    return [t]
Ejemplo n.º 3
0
def exe(entities, params):
    checkReportTable = base.CheckReport('Check GAP Penetrations')

    if entities:
        if not type(entities) is list:
            entities = [entities]
        else:
            for entity in entities:
                try:
                    checkedGap = CheckedGap(entity, checkReportTable)
                    checkedGap.check()
                except CheckedGapException as e:
                    continue

    return [checkReportTable]
Ejemplo n.º 4
0
        def wrappedFcn(*args, **kwargs):
            try:
                ret = fcn(*args, **kwargs)
            except Exception as e:
                ret = []
                details = format_exc()
                #				print(details)

                if entityCheckItem is not None and hasattr(
                        entityCheckItem, 'AUTHOR'):
                    author = entityCheckItem.AUTHOR
                else:
                    author = 'N/A, <*****@*****.**>'

                # Prepare error message
                msg = message + ' Please report Traceback to:\n' +\
                 author + '\n\n' + details

                # Create issue in Checks Manager
                err = base.CheckReport('Python errors')
                err.add_issue('error', [], msg)
                ret = [err]

            return ret
Ejemplo n.º 5
0
def exe(entities, params):
    t0 = base.CheckReport('Tied check - 1. wave - master and slave roles')
    t1 = base.CheckReport(
        'Tied check - 2. wave - check of GROUPs names - identification of master or slave role - Tms or Tsl'
    )
    t2 = base.CheckReport(
        'Tied check - 3. wave - check of GROUPs names - check component numbers from PARTs'
    )
    t3 = base.CheckReport(
        'Tied check - 3. wave - check of GROUPs names - check component numbers from PARTs - not possible auto fix'
    )
    t4 = base.CheckReport(
        'Tied check - 4. wave - check of consistency of GROUP names and TIEDs  names'
    )
    t5 = base.CheckReport(
        'Tied check - 5. wave - check of consistency of TIED names and PART TIED  names'
    )
    t100 = base.CheckReport('Tied check - TIEDs are OK')
    t0.has_fix = True
    t1.has_fix = True
    t2.has_fix = True
    t3.has_fix = False
    t4.has_fix = True
    t5.has_fix = True

    if entities:
        if not (type(entities) == list):
            entities = [entities]

        if type(entities) == list:
            for tied_ent in entities:

                tied = tied_cls(tied_ent._id)
                tie = [
                    base.GetEntity(constants.PAMCRASH, "CNTAC", tied_ent._id)
                ]
                tied.get_component_ids()
                # TODO OSError: [Errno5] Input/output error - can't fix
                print(
                    '----------------------------------------------------------'
                )
                print('tied name:', tied._name)
                print('tied_part_name:', tied.tied_part_name)
                print('master_name_id_part:',
                      tied.master_name_id_part['text_list'])
                print('slave_name_id_part:',
                      tied.slave_name_id_part['text_list'])
                print("part slave_name:", tied.part_slave_name)
                print("part master_name: ", tied.part_master_name)
                print("group master_name: ", tied.group_master_name)
                print("group slave_name: ", tied.group_slave_name)
                print("part_slave_composite: ", tied.part_slave_composite)
                print("part_master_composite: ", tied.part_master_composite)
                print("part_master_h: ", tied.part_master_h)
                print("part_slave_h: ", tied.part_slave_h)

                ############# zero level

                if tied.part_slave_name == " " and tied.part_master_name == " ":
                    name_info = 'Tied ID: \"' + str(
                        tied._id
                    ) + "\" Name: \"" + tied._name + '\" - both master and slave group are empty'
                    t1.add_issue(entities=tie,
                                 status="error",
                                 description=name_info)

                elif tied.part_master_name == " ":
                    name_info = 'Tied ID: \"' + str(
                        tied._id
                    ) + "\" Name: \"" + tied._name + '\" - master group is empty'
                    t1.add_issue(entities=tie,
                                 status="error",
                                 description=name_info)

                elif tied.part_slave_name == " ":
                    name_info = 'Tied ID: \"' + str(
                        tied._id
                    ) + "\" Name: \"" + tied._name + '\" - slave group is empty'
                    t1.add_issue(entities=tie,
                                 status="error",
                                 description=name_info)

                else:
                    if (not (tied.part_slave_composite)
                            and tied.part_master_composite):
                        status = False
                    if (not (tied.part_master_composite)
                            and (tied.part_slave_composite)):
                        status = True
                    if (not (tied.part_slave_composite)
                            and not (tied.part_master_composite)):
                        if (tied.part_slave_h <= tied.part_master_h):
                            status = True
                        else:
                            status = False
                    if ((tied.part_slave_composite)
                            and (tied.part_master_composite)):
                        if (tied.part_slave_h <= tied.part_master_h):
                            status = True
                        else:
                            status = False
                    if status == False:
                        name_info = 'Tied ID: \"' + str(
                            tied._id
                        ) + "\" Name: \"" + tied._name + '\" - you should switch the master and slave group'
                        t0.add_issue(entities=tie,
                                     status="error",
                                     description=name_info)
                        status_groups = "Error"
                    name_info = ""
                    if status == True:
                        status_groups = "OK"
                        name_info = 'Tied ID: \"' + str(
                            tied._id) + "\" Name: \"" + tied._name + '\"  '

                        ############# first level

                        flag_1_level_error = True
                        flag_2_level_error = True
                        flag_3_level_error = True
                        flag_4_level_error = True
                        flag_5_level_error = True

                        if not ("Tms" in tied.group_master_name):
                            name_info = name_info + ' in master \"GROUP  NAME \" missing Tms |'
                            status_groups = "Warning"
                            flag_1_level_error = False
                            print('----------------------------')

                        if not ("Tsl" in tied.group_slave_name):
                            name_info = name_info + ' in slave \"GROUP  NAME \" missing Tsl |'
                            status_groups = "Warning"
                            flag_1_level_error = False
                            print('----------------------------')

                        ############# second level

                        if flag_1_level_error:
                            if ((str(tied.master_name_id_part["text_list"]) !=
                                 str(tied.master_name_id_group["text_list"]))):
                                name_info = name_info + 'Component id doesn\'t match with master \"GROUP NAME\" ' +str(tied.master_name_id_group["text_list"])+ \
                                 ' and master part name '+ str (tied.master_name_id_part["text_list"]) + ' | '
                                status_groups = "Warning"
                                flag_2_level_error = False

                            if ((str(tied.slave_name_id_part["text_list"]) !=
                                 str(tied.slave_name_id_group["text_list"]))):
                                name_info = name_info + 'Component id doesn\'t match with slave \"GROUP NAME\" '+str(tied.slave_name_id_group["text_list"])+ \
                                 ' and slave part name ' + str (tied.slave_name_id_part["text_list"]) + ' | '
                                status_groups = "Warning"
                                flag_2_level_error = False

                            if ((str(tied.master_name_id_part["text_list"]) !=
                                 str(tied.
                                     slave_name_id_group_master["text_list"])
                                 )):
                                name_info = name_info + 'Second component id doesn\'t match with slave \"GROUP NAME\" ' +str(tied.slave_name_id_group_master["text_list"])+ \
                                 ' and master part name '+ str (tied.master_name_id_part["text_list"]) + ' | '
                                status_groups = "Warning"
                                flag_2_level_error = False

                            if ((str(tied.slave_name_id_part["text_list"]) !=
                                 str(tied.
                                     master_name_id_group_slave["text_list"])
                                 )):
                                name_info = name_info + 'Component id doesn\'t match with master \"GROUP NAME\" '+str(tied.master_name_id_group_slave["text_list"])+ \
                                 ' and slave part name ' + str (tied.slave_name_id_part["text_list"]) + ' | '
                                status_groups = "Warning"
                                flag_2_level_error = False
                        ############# third level
                        if flag_2_level_error and flag_1_level_error:
                            if (not (str(tied.master_name_id_part["text_list"])
                                     in tied.
                                     master_name_id_part__slave["text_list"])):
                                status_groups = "Warning"
                                name_info = name_info + 'Component id from master \"GROUP NAME\" '+ str(tied.master_name_id_part["text_list"])+\
                                   ' doesn\'t match component id from slave part name behind the \"glue_to\"'+ str(tied.master_name_id_part__slave["text_list"]) + ' | '
                                flag_3_level_error = False

                            if (not (str(tied.slave_name_id_part["text_list"])
                                     in tied.
                                     slave_name_id_part__master["text_list"])):
                                status_groups = "Warning"
                                name_info = name_info + ' Component id from slave \"GROUP NAME\" '+ str(tied.slave_name_id_part["text_list"])+\
                                   ' doesn\'t match component id from master part name behind the \"glue_to\" '+ str(tied.slave_name_id_part__master["text_list"])
                                flag_3_level_error = False

                        ############# fourth level ####### check the TIED name
                        if flag_2_level_error and flag_1_level_error:
                            if (str(tied.tied_name_component_id_1["text_list"])
                                    != str(
                                        tied.master_name_id_group["text_list"])
                                ):
                                status_groups = "Warning"
                                name_info = name_info + 'The first component id from \"TIED NAME\" '+tied.tied_name_component_id_1["text_list"]+\
                                   ' doesn match with master name group '+ str (tied.master_name_id_group["text_list"])+'. '
                                flag_4_level_error = False

                            if (str(tied.tied_name_component_id_2["text_list"])
                                    != str(
                                        tied.slave_name_id_group["text_list"])
                                ):
                                status_groups = "Warning"
                                name_info = name_info + 'The second  component id from \"TIED NAME\" '+str(tied.tied_name_component_id_2["text_list"])+\
                                   ' doesn match with slave name group '+str (tied.slave_name_id_group["text_list"])+'. '
                                flag_4_level_error = False

                        ############# fifth level ###### check the PART TIED name
                        if flag_2_level_error and flag_1_level_error and flag_4_level_error:
                            if (tied.tied_part_name_component_id_1["text_list"]
                                    != str(
                                        tied.master_name_id_group["text_list"])
                                ):

                                status_groups = "Warning"
                                name_info = name_info + 'The first component id from \"PART TIED NAME\" name: '+tied.tied_part_name_component_id_1["text_list"]+\
                                   ' doesn match with  component of master GROUP NAME: '+str(tied.master_name_id_group["text_list"])
                                flag_5_level_error = False

                            if (tied.tied_part_name_component_id_2["text_list"]
                                    != str(
                                        tied.slave_name_id_group["text_list"])
                                ):

                                status_groups = "Warning"
                                name_info = name_info + 'The second component id from \"PART TIED NAME\" name: '+tied.tied_part_name_component_id_2["text_list"]+\
                                   ' doesn match with  component of slave GROUP NAME: '+str(tied.slave_name_id_group["text_list"])
                                flag_5_level_error = False

                        if status_groups == "OK":
                            name_info = 'Tied is OK - ID: \"' + str(
                                tied._id) + "\" Name: \"" + tied._name + '\"  '
                            status_groups = "Warning"
                            t100.add_issue(entities=tie,
                                           status=status_groups,
                                           description=name_info)
                        if status_groups == "Error":
                            t0.add_issue(entities=tie,
                                         status=status_groups,
                                         description=name_info)
                        elif not (flag_1_level_error):
                            t1.add_issue(entities=tie,
                                         status=status_groups,
                                         description=name_info)
                        elif not (flag_2_level_error):
                            t2.add_issue(entities=tie,
                                         status=status_groups,
                                         description=name_info)
                        elif not (flag_4_level_error):
                            t4.add_issue(entities=tie,
                                         status=status_groups,
                                         description=name_info)
                        elif not (flag_5_level_error):
                            t5.add_issue(entities=tie,
                                         status=status_groups,
                                         description=name_info)
                        if not (flag_3_level_error):
                            t3.add_issue(entities=tie,
                                         status=status_groups,
                                         description=name_info)

    return [t0, t1, t2, t3, t4, t5, t100]
Ejemplo n.º 6
0
def exe(entities, params):
    i = 0
    criteria_matrix_1 = list()
    criteria_matrix_2 = list()
    criteria_matrix = list()
    criteria_percent = list()
    global qualit
    qualit = {}
    qual_n = ('MIN-LEN', 'MAX-LEN')
    for parameter_name, parameter_value in params.items():
        criteria = parameter_value
        criteria_value = criteria.split(":")
        criteria_limits = criteria_value[0]

        criteria_matrix = list()
        criteria_percent = list()
        if "LEN" in parameter_name:
            i = i + 1
            criteria_limit = criteria_limits.split(",")
            criteria_matrix_2 = list()
            for limit in criteria_limit:
                lim = limit.split("-")
                criteria_matrix_1 = list()
                for l in lim:
                    criteria_matrix_1.append(l)
                criteria_matrix_2.append(criteria_matrix_1)

            criteria_matrix.extend(criteria_matrix_2)
            criteria_percent.append(criteria_value[1])
            qualit[parameter_name] = criteria_matrix, criteria_percent

    total_len = len(entities)
    lenght = list()

    for ent in entities:
        qual = base.ElementQuality(ent, qual_n)
        lenght.append([ent._id, qual[0], qual[1]])

    h = {}
    i = {}
    j = {}
    for it, criteria in qualit.items():
        i[it] = 0
        j[it] = 0
        h[it] = []
    for min in lenght:
        for it, criteria in qualit.items():
            crit_1 = criteria[0]
            number_criteria = len(crit_1)

            if number_criteria == 2:

                if crit_1[0][0] and crit_1[0][1] and crit_1[1][0] and crit_1[
                        1][1]:

                    if float(min[1]) > float(crit_1[0][0]) and float(
                            min[1]) < float(crit_1[0][1]):

                        i[it] = i[it] + 1
                        h[it].append(
                            base.Entity(constants.PAMCRASH, min[0], "SHELL"))
                    elif float(min[2]) > float(crit_1[1][0]) and float(
                            min[2]) < float(crit_1[1][1]):

                        i[it] = i[it] + 1
                        h[it].append(
                            base.Entity(constants.PAMCRASH, min[0], "SHELL"))

            if number_criteria == 1:

                if crit_1[0][0] and crit_1[0][1]:
                    if min[1] > float(crit_1[0][0]) and min[2] < float(
                            crit_1[0][1]):
                        i[it] = i[it] + 1
                        h[it].append(
                            base.Entity(constants.PAMCRASH, min[0], "SHELL"))

    t1 = base.CheckReport('Origin criteria')
    t2 = base.CheckReport('Weak glue creteria')
    t3 = base.CheckReport('Weak creteria')
    t1.has_fix = True
    t2.has_fix = True
    t3.has_fix = True

    for it, criteria in qualit.items():
        status = 'OK'
        number = 0
        cr_1 = criteria[1]
        cr = cr_1[0]
        return_val = 0
        u = evaluate_percents(cr, total_len, len(h[it]))
        name_info = 'Status of Criteria ' + it + " - number of shells in range:" + str(
            len(h[it])) + ' percent:' + str(
                u[0]) + '  percent target:' + str(cr)

        if "old" in it:
            t1.add_issue(entities=h[it], status=u[2], description=name_info)
            t = 1
        elif "new - glue" in it:
            t2.add_issue(entities=h[it], status=u[2], description=name_info)
        elif "new" in it:
            t3.add_issue(entities=h[it], status=u[2], description=name_info)

    return [t1, t2, t3]
Ejemplo n.º 7
0
def exe(entities, params):
    solver = params['Solver']
    solver_name = solver.upper()
    if solver_name == 'ABAQUS' or solver_name == 'PAMCRASH':
        if solver_name == 'ABAQUS':
            solver = constants.ABAQUS
            ent = ["SHELL_SECTION", "SOLID_SECTION", "MEMBRANE_SECTION"]
            id_mat = 'MID'
            thickness = 'T'
            remove_text = "_SECTION"
        if solver_name == 'PAMCRASH':
            solver = constants.PAMCRASH
            ent = ["PART_SHELL", "PART_SOLID", "PART_MEMBRANE"]
            id_mat = 'IMAT'
            remove_text = "PART_"
            thickness = 'h'
            c_thickness = 'TCONT'
    # else:
    # session.Quit()

    t5 = base.CheckReport('Thickness same as in part name')
    t7 = base.CheckReport('Material same as in part name')

    t5.has_fix = False
    t7.has_fix = False

    m = utils.SelectOpenFile(0, 'Excel files (*.xlsx)')
    if len(m):
        print('Used :', m[0])
        xl_parts = utils.XlsxOpen(m[0])

        # read excel, find cell position of part name params['Excel part name identifier']
        row = 0
        empty_row = 0
        Component_column = -1
        Component_row = 0
        Component_name = params['Excel part name identifier']
        Component_name = Component_name.replace("\r", "")
        Component_name = Component_name.replace("\n", "")
        Component_name = Component_name.replace(" ", "")
        while (empty_row < 20 and Component_column == -1):
            empty_column = 0
            column = 0
            while (empty_column < 20 and Component_column == -1):
                value = utils.XlsxGetCellValue(xl_parts,
                                               params['Excel sheet name'], row,
                                               column)
                if value != None and value != '':
                    value = value.replace("\r", "")
                    value = value.replace("\n", "")
                    value = value.replace(" ", "")
                    empty_column = 0
                    if value == Component_name:
                        Component_column = column
                        Component_row = row
                else:
                    empty_column += 1
                column += 1
            if column == empty_column:
                empty_row += 1
            row += 1
        # print('Component_column:',Component_column)
        # print('Component_row:',Component_row)
        if Component_column == -1:
            print('NOT FOUND cell with name "',
                  params['Excel part name identifier'], '" in file ', m[0],
                  'in sheet ', params['Excel sheet name'])
            # session.Quit()

        # read excel, find cell position of part nummer name params['Excel part number name identifier']
        empty_column = 0
        column = 0
        P_N_column = -1
        P_N_name = params['Excel part number name identifier']
        P_N_name = P_N_name.replace("\r", "")
        P_N_name = P_N_name.replace("\n", "")
        P_N_name = P_N_name.replace(" ", "")
        while (empty_column < 20 and P_N_column == -1):
            value = utils.XlsxGetCellValue(xl_parts,
                                           params['Excel sheet name'],
                                           Component_row, column)
            if value != None and value != '':
                value = value.replace("\r", "")
                value = value.replace("\n", "")
                value = value.replace(" ", "")
                empty_column = 0
                if value == P_N_name:
                    P_N_column = column
            else:
                empty_column += 1
            column += 1
        # print('P_N_column:',P_N_column)
        if P_N_column == -1:
            print('NOT FOUND cell with name "',
                  params['Excel part number name identifier'], '" in file ',
                  m[0], 'in sheet ', params['Excel sheet name'])
            # session.Quit()

        # read excel, find cell position of part material name params['Excel material name identifier']
        empty_column = 0
        column = 0
        Material_column = -1
        Material_name = params['Excel material name identifier']
        Material_name = Material_name.replace("\r", "")
        Material_name = Material_name.replace("\n", "")
        Material_name = Material_name.replace(" ", "")
        while (empty_column < 20):
            value = utils.XlsxGetCellValue(xl_parts,
                                           params['Excel sheet name'],
                                           Component_row, column)
            if value != None and value != '':
                value = value.replace("\r", "")
                value = value.replace("\n", "")
                value = value.replace(" ", "")
                empty_column = 0
                if value == Material_name:
                    Material_column = column
            else:
                empty_column += 1
            column += 1
        # print('Material_column:',Material_column)
        if Material_column == -1:
            print('NOT FOUND cell with name "',
                  params['Excel material name identifier'], '" in file ', m[0],
                  'in sheet ', params['Excel sheet name'])
            # session.Quit()

        # read excel, find cell position of part thickness name 't \r\n[mm]'
        empty_column = 0
        column = 0
        Th_column = -1
        Th_name = params['Excel thickness name identifier']
        Th_name = Th_name.replace("\r", "")
        Th_name = Th_name.replace("\n", "")
        Th_name = Th_name.replace(" ", "")
        while (empty_column < 20):
            value = utils.XlsxGetCellValue(xl_parts,
                                           params['Excel sheet name'],
                                           Component_row, column)
            if value != None and value != '':
                value = value.replace("\r", "")
                value = value.replace("\n", "")
                value = value.replace(" ", "")
                empty_column = 0
                if value == Th_name:
                    Th_column = column
            else:
                empty_column += 1
            column += 1
        # print('Th_column:',Th_column)
        if Th_column == -1:
            print('NOT FOUND cell with name of thickness in file ', m[0],
                  'in sheet ', params['Excel sheet name'])
            # session.Quit()
        row = Component_row + 1
        empty = 0
        parts = 0
        excel_part_id = list()
        excel_part_name = list()
        excel_part_thickness = list()
        excel_part_mat = list()

        value = utils.XlsxGetCellValue(xl_parts, params['Excel sheet name'],
                                       row, Component_column)
        while empty < 20:
            if value != None and value != '':
                part_name = value
                print('excel_part_name:', part_name)
                part_id = utils.XlsxGetCellValue(xl_parts,
                                                 params['Excel sheet name'],
                                                 row, P_N_column)
                print('excel_part_id:', part_id)
                value = utils.XlsxGetCellValue(xl_parts,
                                               params['Excel sheet name'], row,
                                               Th_column)
                try:
                    part_thickness = float(value)
                    print('excel_part_thickness:', part_thickness)
                except ValueError:
                    part_thickness = float(0.)
                part_mat = utils.XlsxGetCellValue(xl_parts,
                                                  params['Excel sheet name'],
                                                  row, Material_column)
                print('excel_part_mat:', part_mat)
                empty = 0
                excel_part_id.append(part_id)
                excel_part_name.append(part_name)
                excel_part_thickness.append(part_thickness)
                excel_part_mat.append(part_mat)
            else:
                empty += 1
            row += 1
            value = utils.XlsxGetCellValue(xl_parts,
                                           params['Excel sheet name'], row,
                                           Component_column)
            name_list = value.split('Battery Case Assembly')
            if len(name_list) > 1:
                empty = 20

        parts = base.CollectEntities(solver,
                                     entities,
                                     ent,
                                     prop_from_entities=True)
        deck = base.CurrentDeck()

        for part in parts:
            name = part._name
            name_list = name.split(params['Delimiter for part name'])
            pid_name = name_list[int(params['Segment of part name']) - 1]
            identifier = -1
            for interval in range(len(excel_part_name)):
                if (len(pid_name.split(excel_part_name[interval])) > 1
                        and len(pid_name.split(excel_part_id[interval])) > 1):
                    print('find_excel_part_name:', pid_name, ' vs.:',
                          excel_part_id[interval], '_',
                          excel_part_name[interval])
                    identifier = interval

            if identifier != -1:

                # check of thickness by info from part name
                if str(params['Thickness by part name check']) == 'YES':
                    # print('Segment of thickness name :',params['Segment of thickness name'])
                    # print('excel value :',excel_part_thickness[identifier])
                    if (str(params['Segment of thickness name']) != "0" and
                            str(params['Segment of thickness name']) != "var"
                        ) and str(params['Segment of thickness name']) != "":
                        thickness_from_part_name = name_list[
                            int(params['Segment of thickness name']) - 1]
                        thickness_from_part_name = thickness_from_part_name.replace(
                            "mm", "")
                        thickness_from_part_name = thickness_from_part_name.replace(
                            "t", "")
                        thickness_from_part_name = thickness_from_part_name.replace(
                            "_", "")
                        if float(excel_part_thickness[identifier]) != float(
                                thickness_from_part_name):
                            if float(excel_part_thickness[identifier]) > 0.:
                                t5.add_issue(
                                    entities=[part],
                                    status='Error',
                                    description='Thickness is different than '
                                    + str(excel_part_thickness[identifier]),
                                    thickness=str(thickness_from_part_name),
                                    thickness_suggest=str(
                                        excel_part_thickness[identifier]),
                                    key=thickness,
                                    solver=str(solver))
                            else:
                                t5.add_issue(
                                    entities=[part],
                                    status='Warning',
                                    description='Thickness is different than '
                                    + str(excel_part_thickness[identifier]),
                                    thickness=str(thickness_from_part_name),
                                    key=thickness,
                                    solver=str(solver))

                # check of material by info from part name
                if str(params['Material by part name check']) == 'YES':
                    # print('Segment of material name :',params['Segment of material name'])
                    # print('excel value :',excel_part_mat[identifier])
                    if (str(params['Segment of material name']) != "0" and
                            str(params['Segment of material name']) != "var"
                        ) and str(params['Segment of material name']) != "":
                        material_from_part_name = name_list[
                            int(params['Segment of material name']) - 1]
                        if excel_part_mat[
                                identifier] != material_from_part_name:
                            t7.add_issue(
                                entities=[part],
                                status='Error',
                                description='Material is different than ' +
                                str(excel_part_mat[identifier]),
                                thickness=str(material_from_part_name),
                                thickness_suggest=str(
                                    excel_part_mat[identifier]),
                                key=thickness,
                                solver=str(solver))

        CheckItem.reports.append(t5)
        CheckItem.reports.append(t7)
    else:
        print('Excel file was not chosen.')
        # session.Quit()

    return CheckItem.reports
Ejemplo n.º 8
0
def exe(entities, params):
    t0 = time.time()
    print('start measure time')
    mesh.ReadQualityCriteria(params['Quality mesh file'])

    # Solver dependent variables
    solver = params['Solver']
    solver_name = solver.upper()
    limit_lines = int(params['Detail list for number of errors'])
    if solver_name == 'ABAQUS' or solver_name == 'PAMCRASH':
        if solver_name == 'ABAQUS':
            solver = constants.ABAQUS
            ent = ["SHELL_SECTION", "SOLID_SECTION", "MEMBRANE_SECTION"]
            thickness = 'T'
            remove_text = "_SECTION"
            name_part_key = 'PID'
        if solver_name == 'PAMCRASH':
            solver = constants.PAMCRASH
            ent = ["PART_SHELL", "PART_SOLID", "PART_MEMBRANE"]
            thickness = 'h'
            c_thickness = 'TCONT'
            name_part_key = 'IPART'
    else:
        session.Quit()

    # Basic criteria
    criterias = { \
     'ASPECT,SHELL,QUAD,TRIA':{'criteria name F11': 'aspect ratio', 'comparison':'<','type':'QUAD,TRIA'},
     'SKEW,SHELL,QUAD,TRIA':{'criteria name F11':"skewness",'comparison':'<','type':'QUAD,TRIA'},
     'WARP,SHELL,QUAD':{'criteria name F11':"warping",'comparison':'<','type':'QUAD'},
     'TAPER,SHELL,QUAD':{'criteria name F11':"taper",'comparison':'>','type':'QUAD'},
     'CRASH,SHELL,QUAD,TRIA':{'criteria name F11':"crash time step",'comparison':'>','type':'QUAD,TRIA'},
     'MIN HEI,SHELL,QUAD,TRIA':{'criteria name F11':"min height",'comparison':'>','type':'QUAD,TRIA'},
     'MIN-LEN,SHELL,QUAD,TRIA':{'criteria name F11':"min length",'comparison':'>','type':'QUAD,TRIA'},
     'MINANGLE,SHELL,QUAD':{'criteria name F11':"min angle quads",'comparison':'>','type':'QUAD'},
     'MAXANGLE,SHELL,QUAD':{'criteria name F11':"max angle quads",'comparison':'<','type':'QUAD'},
     'MINANGLE,SHELL,TRIA':{'criteria name F11':"min angle trias",'comparison':'>','type':'TRIA'},
     'MAXANGLE,SHELL,TRIA':{'criteria name F11':"max angle trias",'comparison':'<','type':'TRIA'},
     'TRIANGLES PER NODE,SHELL,QUAD,TRIA':{'criteria name F11':"triangles per node",'comparison':'<=','type':'QUAD,TRIA'},
     'ASPECT,SOLID,TETRA,HEXA,PENTA':{'criteria name F11': 'aspect ratio', 'comparison':'<','type':'TETRA,HEXA,PENTA'},
     'SKEW,SOLID,TETRA,HEXA,PENTA':{'criteria name F11':"skewness",'comparison':'<','type':'TETRA,HEXA,PENTA'},
     'WARP,SOLID,TETRA,HEXA,PENTA':{'criteria name F11':"warping",'comparison':'<','type':'TETRA,HEXA,PENTA'},
     'CRASH,SOLID,TETRA,HEXA,PENTA':{'criteria name F11':"crash time step",'comparison':'>','type':'TETRA,HEXA,PENTA'},
     'MIN-LEN,SOLID,TETRA,HEXA,PENTA':{'criteria name F11':"min length",'comparison':'>','type':'TETRA,HEXA,PENTA'},
     'MINANGLE,SOLID,TETRA':{'criteria name F11':"min angle tetras",'comparison':'>','type':'TETRA'},
     'MAXANGLE,SOLID,TETRA':{'criteria name F11':"max angle tetras",'comparison':'<','type':'TETRA'},
     'MINANGLE,SOLID,HEXA':{'criteria name F11':"min angle hexas",'comparison':'>','type':'HEXA'},
     'MAXANGLE,SOLID,HEXA':{'criteria name F11':"max angle hexas",'comparison':'<','type':'HEXA'},
     'MINANGLE,SOLID,PENTA':{'criteria name F11':"min angle pentas",'comparison':'>','type':'PENTA'},
     'MAXANGLE,SOLID,PENTA':{'criteria name F11':"max angle pentas",'comparison':'<','type':'PENTA'}}

    criterias_type_ent = {}
    criterias_type_val = {}
    criterias_type_oper = {}
    criterias_val = {}
    t = {}

    # Reorder criteria for checking
    for key, val in criterias.items():
        key = key.split(',')
        if key[1] == 'SOLID':
            m = base.F11SolidsOptionsGet(val['criteria name F11'])
        if key[1] == 'SHELL':

            m = base.F11ShellsOptionsGet(val['criteria name F11'])
        if m['status'] == 1:
            val['val'] = m['value']
            criterias_val[key[0] + ',' + key[1]] = val

            for ty in val['type'].split(','):
                disct_text = key[1] + ',' + ty

                # Type of entity
                if disct_text in criterias_type_ent:
                    criterias_type_ent[disct_text] = criterias_type_ent[
                        disct_text] + [key[0]]
                else:
                    criterias_type_ent[disct_text] = [key[0]]

                # Value of limit
                if disct_text in criterias_type_val:
                    criterias_type_val[disct_text] = criterias_type_val[
                        disct_text] + [m['value']]
                else:
                    criterias_type_val[disct_text] = [m['value']]

                # Operator for comparison
                if disct_text in criterias_type_oper:
                    criterias_type_oper[disct_text] = criterias_type_oper[
                        disct_text] + [val['comparison']]
                else:
                    criterias_type_oper[disct_text] = [val['comparison']]

            t[','.join(key[0:2])] = base.CheckReport(key[1] + ',' + key[0])
            t[','.join(key[0:2])].has_fix = False

    # Collecting entities
    parts = base.CollectEntities(solver,
                                 entities,
                                 ent,
                                 prop_from_entities=True)

    mats = base.CollectEntities(solver,
                                parts,
                                '__MATERIALS__',
                                mat_from_entities=True)

    elements = {}
    elements['SHELL'] = base.CollectEntities(deck=solver,
                                             containers=None,
                                             search_types=['SHELL'],
                                             filter_visible=True)
    elements['SOLID'] = base.CollectEntities(deck=solver,
                                             containers=None,
                                             search_types=['SOLID'],
                                             filter_visible=True)

    # Extracting the thickness parameter from PARTs
    thickness_dict = {}
    for part in parts:
        if part.ansa_type(solver) == 'PART_SHELL':
            thick = part.get_entity_values(solver, [thickness, c_thickness])
        if part.ansa_type(solver) == 'PART_MEMBRANE':
            thick = part.get_entity_values(solver, [thickness])
            thick[c_thickness] = thick[thickness]
        if not thick[c_thickness]:
            thickness_dict[part] = thick[thickness]
        else:
            thickness_dict[part] = thick[c_thickness]

    # Extracting the defined mats
    flag_defined_mat = 'YES'
    for mat in mats:
        defined = mat.get_entity_values(solver, ['DEFINED', 'Name'])
        if defined['DEFINED'] == 'NO':
            flag_defined_mat = 'NO'
            break

    # Checking loops
    i = {}
    en = {}
    for type, elems in elements.items():
        t3 = time.time()
        for ent in elems:
            if type == 'SHELL':
                prop = ent.get_entity_values(solver, ['IPART'])['IPART']
            typ = ent.get_entity_values(solver, ['type'])['type']
            dict_text = type + ',' + typ
            qual = base.ElementQuality(ent, criterias_type_ent[dict_text])
            crit = criterias_type_ent[dict_text]
            limit = criterias_type_val[dict_text]
            oper = criterias_type_oper[dict_text]
            for compare in zip(qual, limit, crit, oper):
                text = compare[2] + ',' + type

                # Standard check for elements
                if text not in i:
                    i[text] = 0
                    en[text] = []

                flag_error = False
                if compare[0] != 'error':
                    if compare[3] == '>':
                        if float(compare[0]) < float(compare[1]):
                            flag_error = True
                            diff = str(compare[1] - compare[0])

                    if compare[3] == '<':

                        if float(compare[0]) > float(compare[1]):
                            flag_error = True
                            diff = str(compare[0] - compare[1])

                    if compare[3] == '<=':
                        if float(compare[0]) >= float(compare[1]):
                            flag_error = True
                            diff = str(compare[0] - compare[1])

                    if flag_error == True:
                        i[text] = i[text] + 1
                        if i[text] < limit_lines:
                            t[text].add_issue(entities=[ent],
                                              status='Error',
                                              description=compare[2] + '  ' +
                                              type,
                                              value=str(compare[0]),
                                              limit=str(compare[1]),
                                              diffe=diff)
                        else:
                            en[text].append(ent)
                else:
                    continue

                # Additional check for lenght - thick * THICKNESS FACTOR
                if type == 'SHELL':
                    if compare[2] == "MIN HEI" or compare[2] == "MIN-LEN":
                        lim = float(thickness_dict[prop]) * float(
                            params['THICKNESS FACTOR'])
                        if compare[0] < lim:
                            i[text] = i[text] + 1
                            if i[text] < limit_lines:
                                diff = str(lim - compare[0])
                                t[text].add_issue(entities=[ent],
                                                  status='Error',
                                                  description=compare[2] +
                                                  ' THICKNESS FACTOR',
                                                  value=str(compare[0]),
                                                  limit=str(lim),
                                                  diff=diff)
                            else:
                                en[text].append(ent)

                    # Check for skewness - user defined
                    if compare[2] == 'SKEW':
                        if typ == 'TRIA':
                            lim = float(params['SKEW,TRIA'])
                        elif typ == 'QUAD':
                            lim = float(params['SKEW,QUAD'])
                        if compare[0] > lim:
                            i[text] = i[text] + 1
                            if i[text] < limit_lines:
                                diff = str(lim - compare[0])
                                t[text].add_issue(entities=[ent],
                                                  status='Error',
                                                  description=compare[2] +
                                                  '  ' + type,
                                                  value=str(compare[0]),
                                                  limit=str(lim),
                                                  diff=diff)
                            else:
                                en[text].append(ent)
        t4 = time.time()
        print('Time of checking the type of entity: ', type)
        print(t4 - t3)

    if i != None:
        for key, val in i.items():
            if val > limit_lines:
                t[key].add_issue(entities=en[key],
                                 status='Error',
                                 description=key + '  number of errors: ' +
                                 str(len(en[key])))

    t5 = time.time()
    print('End of execution of the check: ')
    print(t5 - t0)

    return list(t.values())
def exe(entities, params):

    if base.CurrentDeck() != constants.PAMCRASH:
        base.SetCurrentDeck(constants.PAMCRASH)
        print("Switch form current deck to PAMCRASH")
        print("Please run the check again !!!!")
        return []

    type_check = params['Car - SKODA/DAIMLER']
    element_length = params['Default mesh length']
    THICKNESS_FACTOR = 1.1
    SKEW_TRIA = 60.0
    SKEW_QUAD = 48.0

    t0 = time.time()
    print('Start measure time....')

    if params['User quality mesh file'] != '':
        user_define_qual = True
        success = mesh.ReadQualityCriteria(params['User quality mesh file'])
        if success == 1:
            print('User defined mesh quality file was loaded')
        else:
            print('User defined mesh quality file was\'n loaded')
            session.Quit()

    else:
        if type_check == 'DAIMLER' and params[
                'Material type (polymer/steel)'] == 'polymer' and element_length == '5':
            success = mesh.ReadQualityCriteria(
                os.path.join(PATH_SELF, 'res', 'DAIMLER', 'O5mm.ansa_qual'))
            if success == 1:
                print(
                    'Mesh quality file was loaded - DAIMLER - O5mm.ansa_qual')
            else:
                print('User defined mesh quality file was\'n loaded')
                session.Quit()

        if type_check == 'SKODA' and params[
                'Material type (polymer/steel)'] == 'polymer' and element_length == '5':
            success = mesh.ReadQualityCriteria(
                os.path.join(PATH_SELF, 'res', 'SKODA', 'Plast_5mm.ansa_qual'))
            if success == 1:
                print(
                    'Mesh quality file was loaded - SKODA - Plast_5mm.ansa_qual'
                )
            else:
                print('User defined mesh quality file was\'n loaded')
                session.Quit()

    if success == 0:
        print(
            'Any mesh quality file was\'n loaded - current mesh quality element will be used'
        )

    # Solver dependent variables
    solver = params['Solver']
    solver_name = solver.upper()
    limit_lines = int(params['Detail list for number of errors'])
    if solver_name == 'ABAQUS' or solver_name == 'PAMCRASH' or solver_name == 'LSDYNA':

        if solver_name == 'ABAQUS':
            solver = constants.ABAQUS
            properties_types = {
                'SHELL_SECTION': "SHELL_SECTION",
                "SOLID_SECTION": "SOLID_SECTION",
                "MEMBRANE_SECTION": "MEMBRANE_SECTION",
                'COMPOSITE': 'COMPOSITE',
                'LAMINATE': 'LAMINATE'
            }
            thickness = 'T'
            c_thickness = 'T'
            name_part_key = 'PID'
            element_types = {
                'SHELL': 'SHELL',
                'MEMBRANE': 'MEMBRANE',
                'SOLID': 'SOLID'
            }
            material_key = 'MID'
            material_key_comp = 'MID(1)'

        if solver_name == 'PAMCRASH':
            solver = constants.PAMCRASH
            properties_types = {
                'SHELL_SECTION': "PART_SHELL",
                "SOLID_SECTION": "PART_SOLID",
                "MEMBRANE_SECTION": "PART_MEMBRANE",
                'COMPOSITE': 'COMPOSITE',
                'LAMINATE': 'LAMINATE'
            }
            thickness = 'h'
            c_thickness = 'TCONT'
            name_part_key = 'IPART'
            material_key = 'IMAT'
            material_key_comp = 'IMAT'
            element_types = {
                'SHELL': 'SHELL',
                'MEMBRANE': 'MEMBRANE',
                'SOLID': 'SOLID'
            }

        if solver_name == 'LSDYNA':
            solver = constants.LSDYNA
            properties_types = {
                'SHELL_SECTION': "SECTION_SHELL",
                "SOLID_SECTION": "SECTION_SOLID",
                "MEMBRANE_SECTION": "SECTION_MEMBRANE",
                'COMPOSITE': 'PART_COMPOSITE',
                'LAMINATE': 'LAMINATE'
            }
            thickness = 'T1'
            material_key_comp = 'mid1'
            c_thickness = 'OPTT'
            name_part_key = 'PID'
            material_key = 'MID'
            element_types = {
                'SHELL': 'ELEMENT_SHELL',
                'MEMBRANE': 'MEMBRANE',
                'SOLID': 'ELEMENT_SOLID'
            }
    else:
        session.Quit()

    properties_types_list = [
        typ_property for _, typ_property in properties_types.items()
    ]

    print("SOLVER:", solver_name)

    # Basic criteria
    criterias = {
        'ASPECT,SHELL,QUAD,TRIA': {
            'criteria name F11': 'aspect ratio',
            'comparison': '<',
            'type': 'QUAD,TRIA'
        },
        'SKEW,SHELL,QUAD,TRIA': {
            'criteria name F11': "skewness",
            'comparison': '<',
            'type': 'QUAD,TRIA'
        },
        'WARP,SHELL,QUAD': {
            'criteria name F11': "warping",
            'comparison': '<',
            'type': 'QUAD'
        },
        'TAPER,SHELL,QUAD': {
            'criteria name F11': "taper",
            'comparison': '>',
            'type': 'QUAD'
        },
        'CRASH,SHELL,QUAD,TRIA': {
            'criteria name F11': "crash time step",
            'comparison': '>',
            'type': 'QUAD,TRIA'
        },
        'MIN HEI,SHELL,QUAD,TRIA': {
            'criteria name F11': "min height",
            'comparison': '>',
            'type': 'QUAD,TRIA'
        },
        'MIN-LEN,SHELL,QUAD,TRIA': {
            'criteria name F11': "min length",
            'comparison': '>',
            'type': 'QUAD,TRIA'
        },
        'MINANGLE,SHELL,QUAD': {
            'criteria name F11': "min angle quads",
            'comparison': '>',
            'type': 'QUAD'
        },
        'MAXANGLE,SHELL,QUAD': {
            'criteria name F11': "max angle quads",
            'comparison': '<',
            'type': 'QUAD'
        },
        'MINANGLE,SHELL,TRIA': {
            'criteria name F11': "min angle trias",
            'comparison': '>',
            'type': 'TRIA'
        },
        'MAXANGLE,SHELL,TRIA': {
            'criteria name F11': "max angle trias",
            'comparison': '<',
            'type': 'TRIA'
        },
        'TRIANGLES PER NODE,SHELL,QUAD,TRIA': {
            'criteria name F11': "triangles per node",
            'comparison': '>=',
            'type': 'QUAD,TRIA'
        },
        'ASPECT,SOLID,TETRA,HEXA,PENTA': {
            'criteria name F11': 'aspect ratio',
            'comparison': '<',
            'type': 'TETRA,HEXA,PENTA'
        },
        'SKEW,SOLID,TETRA,HEXA,PENTA': {
            'criteria name F11': "skewness",
            'comparison': '<',
            'type': 'TETRA,HEXA,PENTA'
        },
        'WARP,SOLID,TETRA,HEXA,PENTA': {
            'criteria name F11': "warping",
            'comparison': '<',
            'type': 'TETRA,HEXA,PENTA'
        },
        'CRASH,SOLID,TETRA,HEXA,PENTA': {
            'criteria name F11': "crash time step",
            'comparison': '>',
            'type': 'TETRA,HEXA,PENTA'
        },
        'MIN-LEN,SOLID,TETRA,HEXA,PENTA': {
            'criteria name F11': "min length",
            'comparison': '>',
            'type': 'TETRA,HEXA,PENTA'
        },
        'MINANGLE,SOLID,TETRA': {
            'criteria name F11': "min angle tetras",
            'comparison': '>',
            'type': 'TETRA'
        },
        'MAXANGLE,SOLID,TETRA': {
            'criteria name F11': "max angle tetras",
            'comparison': '<',
            'type': 'TETRA'
        },
        'MINANGLE,SOLID,HEXA': {
            'criteria name F11': "min angle hexas",
            'comparison': '>',
            'type': 'HEXA'
        },
        'MAXANGLE,SOLID,HEXA': {
            'criteria name F11': "max angle hexas",
            'comparison': '<',
            'type': 'HEXA'
        },
        'MINANGLE,SOLID,PENTA': {
            'criteria name F11': "min angle pentas",
            'comparison': '>',
            'type': 'PENTA'
        },
        'MAXANGLE,SOLID,PENTA': {
            'criteria name F11': "max angle pentas",
            'comparison': '<',
            'type': 'PENTA'
        }
    }

    criterias_type_ent = {}
    criterias_type_val = {}
    criterias_type_oper = {}
    criterias_val = {}
    t = {}

    # Reorder criteria for checking
    for key, val in criterias.items():
        key = key.split(',')

        if key[1] == 'SOLID':
            criteria_from_f11 = base.F11SolidsOptionsGet(
                val['criteria name F11'])

        if key[1] == 'SHELL':
            criteria_from_f11 = base.F11ShellsOptionsGet(
                val['criteria name F11'])

        if criteria_from_f11['status'] == 1:
            val['val'] = criteria_from_f11['value']
            criterias_val[key[0] + ',' + key[1]] = val

            for ty in val['type'].split(','):
                disct_text = key[1] + ',' + ty

                # Type of entity
                if disct_text in criterias_type_ent:
                    criterias_type_ent[disct_text] = criterias_type_ent[
                        disct_text] + [key[0]]
                else:
                    criterias_type_ent[disct_text] = [key[0]]
                # Value of limit
                if disct_text in criterias_type_val:
                    criterias_type_val[disct_text] = criterias_type_val[
                        disct_text] + [criteria_from_f11['value']]
                else:
                    criterias_type_val[disct_text] = [
                        criteria_from_f11['value']
                    ]

                # Operator for comparison
                if disct_text in criterias_type_oper:
                    criterias_type_oper[disct_text] = criterias_type_oper[
                        disct_text] + [val['comparison']]
                else:
                    criterias_type_oper[disct_text] = [val['comparison']]

            t[','.join(key[0:2])] = base.CheckReport(key[1] + ',' + key[0])
            t[','.join(key[0:2])].has_fix = False

    t['Check of materials DEFINED = YES'] = base.CheckReport(
        'Check of materials DEFINED = YES')
    t['Check of materials DEFINED = YES'].has_fix = False

    # Collecting entities
    parts = base.CollectEntities(solver,
                                 entities,
                                 properties_types_list,
                                 prop_from_entities=True)

    mats = base.CollectEntities(solver,
                                parts,
                                '__MATERIALS__',
                                mat_from_entities=True)

    # Extracting the thickness parameter from PARTs

    thickness_dict = dict()
    defined_material = dict()
    text_errors_mat = list()
    thick = dict()

    for part in parts:

        if part.ansa_type(solver) == properties_types['SOLID_SECTION']:
            continue

        if part.ansa_type(solver) == properties_types['SHELL_SECTION']:
            thick = part.get_entity_values(solver, [thickness, c_thickness])

        if part.ansa_type(
                solver) == properties_types['LAMINATE'] or part.ansa_type(
                    solver) == properties_types['COMPOSITE']:
            thick[thickness] = 10000

        if part.ansa_type(solver) == properties_types['MEMBRANE_SECTION']:
            thick = part.get_entity_values(solver, [thickness])
            thick[c_thickness] = thick[thickness]

        if c_thickness in thick:
            thickness_dict[part] = thick[c_thickness]
        else:
            thickness_dict[part] = thick[thickness]

        # # Extracting the defined mats
        if type_check == 'SKODA':
            part_type = part.ansa_type(solver)
            if part_type == 'LAMINATE':
                material_key = material_key_comp
#            print('part', part)

            mat = part.get_entity_values(solver, [material_key])[material_key]
            defined = mat.get_entity_values(solver, ['DEFINED'])

            if defined['DEFINED'] == 'NO':
                defined_material[part] = False
                text = 'The material id = ' + str(
                    mat._id
                ) + ' wasn\'t defined - the check the CRASH TIME STEP was skipped'

                if not (text in text_errors_mat):
                    t['Check of materials DEFINED = YES'].add_issue(
                        entities=[mat],
                        status='Error',
                        description=text,
                        value="",
                        diff="")
                text_errors_mat.append(text)
            else:
                defined_material[part] = True

    # Checking loops
    number_errors = {}
    text_errors = {}
    #print(len(entities))
    for element in entities:

        element_type = element.ansa_type(solver)

        if element_type == element_types['SHELL']:
            prop = element.get_entity_values(solver,
                                             [name_part_key])[name_part_key]
            element_type_universal = 'SHELL'
        elif element_type == element_types['SOLID']:
            element_type_universal = 'SOLID'
        elif element_type == element_types['MEMBRANE']:
            element_type_universal = 'MEMBRANE'

        typ = element.get_entity_values(solver, ['type'])['type']
        dict_text = element_type_universal + ',' + typ

        qual = base.ElementQuality(element, criterias_type_ent[dict_text])
        crit = criterias_type_ent[dict_text]
        limit = criterias_type_val[dict_text]
        oper = criterias_type_oper[dict_text]

        for compare in zip(qual, limit, crit, oper):
            text = compare[2] + ',' + element_type_universal

            if text not in number_errors:
                number_errors[text] = 0
                text_errors[text] = []

            # Additional check for lenght - thick * THICKNESS FACTOR
            if element_type == element_types['SHELL'] and type_check == 'SKODA':

                if compare[2] == "MIN HEI" or compare[2] == "MIN-LEN":

                    if thickness_dict[prop]:
                        lim = float(
                            thickness_dict[prop]) * float(THICKNESS_FACTOR)

                        if compare[0] < lim:

                            number_errors[text] = number_errors[text] + 1

                            if number_errors[text] < limit_lines:
                                diff = str(lim - compare[0])
                                t[text].add_issue(entities=[element],
                                                  status='Error',
                                                  description=compare[2] +
                                                  ' THICKNESS FACTOR',
                                                  value=str(compare[0]),
                                                  limit=str(lim),
                                                  diff=diff)
                            else:
                                text_errors[text].append(element)
                    continue

                # Check for skewness - user defined
                if compare[2] == 'SKEW':
                    if typ == 'TRIA':
                        lim = float(SKEW_TRIA)
                    elif typ == 'QUAD':
                        lim = float(SKEW_QUAD)
                    if compare[0] > lim:

                        number_errors[text] = number_errors[text] + 1
                        if number_errors[text] < limit_lines:
                            diff = str(lim - compare[0])
                            t[text].add_issue(entities=[element],
                                              status='Error',
                                              description=compare[2] + ',' +
                                              element_type_universal,
                                              value=str(compare[0]),
                                              limit=str(lim),
                                              diff=diff)
                        else:
                            text_errors[text].append(element)
                    continue

            # Check for solid angle MIN HEI only for TETRA
            if (compare[2] == 'MIN HEI' and typ != 'TETRA'
                    and type_check == 'DAIMLER'
                    and element_type == element_types['SOLID']):
                continue

            if (compare[2] == 'CRASH' and not (defined_material[prop])
                    and type_check == 'SKODA'
                    and element_type == element_types['SHELL']):
                continue

            # Standard check for elements

            flag_error = False
            if compare[0] != 'error':
                if compare[3] == '>':
                    if float(compare[0]) < float(compare[1]):
                        flag_error = True
                        diff = str(compare[1] - compare[0])

                if compare[3] == '<':

                    if float(compare[0]) > float(compare[1]):
                        flag_error = True
                        diff = str(compare[0] - compare[1])

                if compare[3] == '<=':

                    if float(compare[0]) >= float(compare[1]):
                        flag_error = True
                        diff = str(compare[0] - compare[1])

                if flag_error == True:

                    number_errors[text] = number_errors[text] + 1

                    if number_errors[text] < limit_lines:

                        t[text].add_issue(entities=[element],
                                          status='Error',
                                          description=compare[2] + ',' +
                                          element_type_universal,
                                          value=str(compare[0]),
                                          limit=str(compare[1]),
                                          diffe=diff)
                    else:
                        text_errors[text].append(element)

    if number_errors != None:
        for key, val in number_errors.items():
            if val > limit_lines:
                t[key].add_issue(entities=text_errors[key],
                                 status='Error',
                                 description=key + '  number of errors: ' +
                                 str(len(text_errors[key])))

    t5 = time.time()
    print('End of execution of the check: ')
    print(t5 - t0)

    return list(t.values())
Ejemplo n.º 10
0
    def createReports(cls):
        ''' At the begining, report tables (groups for issues) are created '''

        for reportName in cls.reportNames:
            cls.reports[reportName] = base.CheckReport(type=reportName)
Ejemplo n.º 11
0
def exe(entities, params):
	file = params['Matching list']

	solver = params['Solver']
	solver_name = solver.upper()

	if solver_name == 'ABAQUS' or solver_name == 'PAMCRASH' or solver_name == 'NASTRAN':
		if solver_name == 'ABAQUS':
			solver = constants.ABAQUS
			ent = ["SHELL_SECTION","SOLID_SECTION", "MEMBRANE_SECTION"]
			id_mat = 'MID'
			remove_text = "_SECTION"
		if solver_name == 'PAMCRASH':
			solver = constants.PAMCRASH
			ent = ["PART_SHELL","PART_SOLID", "PART_MEMBRANE"]
			id_mat = 'IMAT'
			remove_text = "PART_"
		if solver_name == 'NASTRAN':
			solver = constants.NASTRAN
			ent = ["PSHELL","PSOLID"]
			id_mat = 'MID1'
			id_mat_nastran = ['MID1', 'MID2', 'MID3']
			remove_text = "P"
	else:
		print('Check works only for ABAQUS, PAMCRASH and NASTRAN')
		return 0

	if not os.path.isfile(file):
		m = utils.SelectOpenFile(0, 'Matching list (*)')
		file = m[0]
		if not os.path.isfile(file):
			return 0

	configuration_line, configuration_line_short, loadcase_list = read_configuration_file(file)

	loadcase = '' # initialize loadcase to aviod errors due to wrong file format
	if (params['Type of loadcase'] not in loadcase_list) and len(loadcase_list) > 1:
		print(loadcase_list)
		TopWindow = guitk.BCWindowCreate("Fill the  text from the combo box", guitk.constants.BCOnExitDestroy)
		ComboBox = guitk.BCComboBoxCreate(TopWindow,loadcase_list )
		guitk.BCComboBoxSetActivatedFunction( ComboBox, ComboActivated, None )
		guitk.BCShow(TopWindow)
		loadcase = loadcase_choose
	elif params['Type of loadcase'] in loadcase_list:
		loadcase = params['Type of loadcase']

	if len(loadcase_list) == 1:
		loadcase = loadcase_list[0]

	t1 = base.CheckReport('ID of material doesn\'t match with ID in the matching list')
	t2 = base.CheckReport('Wrong format of part')
	t3 = base.CheckReport('The material isn\'t in list')

	t1.has_fix = True
	t2.has_fix = False
	t3.has_fix = False

	parts = base.CollectEntities(solver, entities, ent, prop_from_entities=True)

	for part in parts:
		name = part._name
		name_list = name.split(params['Delimiter for part name'])
		if len(name_list) == int(params['Number of segments']):
			type_part = part.ansa_type(solver)
			type_part = type_part.replace(remove_text, "")

			material = name_list [int(params['Segment of material name']) - 1]
			material_ident = loadcase + ',' + material + ',' + type_part

			material_ent = part.get_entity_values(solver, [id_mat])
			material_id = material_ent[id_mat]._id

			if solver == constants.NASTRAN and type_part == 'SHELL':
				material_ent = part.get_entity_values(solver, id_mat_nastran)
				if material_ent[id_mat_nastran[0]]._id == material_ent[id_mat_nastran[1]]._id and \
					material_ent[id_mat_nastran[0]]._id == material_ent[id_mat_nastran[2]]._id:
					flag_nastran_same_mat = True
				else:
					flag_nastran_same_mat = False

			# the material was find at in matching list
			if material_ident in configuration_line:
				# the material was find at in matching list, but with wrong id
				if solver == constants.NASTRAN and type_part == 'SHELL':
					if int(configuration_line[material_ident]) != int(material_id) or not flag_nastran_same_mat:
						t1.add_issue(entities=[part], status='Error', description='Wrong assigning ID or MIDx are not same ',
							material=material, loadcase=str(loadcase),
							matching_mat_ID=str(configuration_line[material_ident]),
							mat_card_ID=str(material_ent[id_mat_nastran[0]]._id) +
								'/' + str(material_ent[id_mat_nastran[1]]._id) +  '/' +
								str(material_ent[id_mat_nastran[2]]._id),
							solver_name=solver_name, _solver=str(solver), mat=id_mat )
				else:
					if int(configuration_line[material_ident]) != int(material_id):
						t1.add_issue(entities = [part], status = 'Error', description = 'Wrong assigning ID',
							material = material,
							loadcase = str(loadcase),
							matching_mat_ID = str(configuration_line[material_ident]),
							mat_card_ID = str(material_id),
							solver_name =  solver_name,
							_solver = str(solver),
							mat = id_mat,
							)
			else:
				# the material wasnt able to find at in matching list
				material_ident_short = material + ',' + type_part
				if material_ident_short in configuration_line_short:
					suggest = configuration_line_short [material_ident_short]
				else:
					suggest = ['xxx','xxx']

				t3.add_issue(entities = [part], status = 'Error',
					description = 'The material isn\'t in list',
					material = material,
					suggest = str(suggest),
					loadcase = str(loadcase),
					solver_name =  solver_name,
					mat_card_ID = str(material_id),
					)
		else:
			# Wrong numer of segments
			t2.add_issue(entities = [part], status = 'Error', description = 'Wrong numer of segments')

	return [t1, t2, t3]
Ejemplo n.º 12
0
def exe(entities, params):

    solver = params['Solver']
    solver_name = solver.upper()
    if solver_name == 'ABAQUS' or solver_name == 'PAMCRASH':
        if solver_name == 'ABAQUS':
            solver = constants.ABAQUS
            ent = ["SHELL_SECTION", "SOLID_SECTION", "MEMBRANE_SECTION"]
            id_mat = 'MID'
            thickness = 'T'
            remove_text = "_SECTION"
        if solver_name == 'PAMCRASH':
            solver = constants.PAMCRASH
            ent = ["PART_SHELL", "PART_SOLID", "PART_MEMBRANE"]
            id_mat = 'IMAT'
            remove_text = "PART_"
            thickness = 'h'
            c_thickness = 'TCONT'
    else:
        session.Quit()

    t4 = base.CheckReport('Number of segments')
    t5 = base.CheckReport('Thickness same as in part name')
    t6 = base.CheckReport('Rounding of thickness')
    t7 = base.CheckReport('Filling the TCONT based on SKODA')
    t8 = base.CheckReport('Lenght of part name')

    t4.has_fix = False
    t5.has_fix = True
    t6.has_fix = True
    t7.has_fix = True
    t8.has_fix = False

    parts = base.CollectEntities(solver,
                                 entities,
                                 ent,
                                 prop_from_entities=True)
    deck = base.CurrentDeck()

    for part in parts:
        name = part._name
        name_list = name.split(params['Delimiter for part name'])
        thickness_number = part.get_entity_values(solver, [thickness])
        if thickness_number:
            thickness_number = float(thickness_number[thickness])
        else:
            thickness_number = 0.0

        # Check of number of segments
        if len(name_list) != int(params['Number of segments']):
            t4.add_issue(entities=[part],
                         status='Error',
                         description='Wrong numer of segment')

        else:
            # Check of number of chars
            if len(name) > int(params['Max. number of chars']):
                t8.add_issue(entities=[part],
                             status='Error',
                             description='The lenght is bigger then ' +
                             str(params['Max. number of chars']))

            # Check of rouding
            thickness_number_round = round(
                thickness_number,
                int(params['Number of digits for thickness']))
            if float(thickness_number) != thickness_number_round:
                t6.add_issue(
                    entities=[part],
                    status='Error',
                    description='Thickness -  digits are bigger then ' +
                    str(params['Number of digits for thickness']),
                    thickness=str(thickness_number),
                    thickness_suggest=str(thickness_number_round),
                    __key=thickness,
                    __solver=str(solver))

            # Check of thickness by info from part name
            if str(params['Thickness by part name check']) == 'YES':
                if (str(params['Segment of thickness name']) != "0"
                        and str(params['Segment of thickness name']) != "var"
                    ) and str(params['Segment of thickness name']) != "":
                    thickness_from_part_name = name_list[
                        int(params['Segment of thickness name']) - 1]
                    thickness_from_part_name = thickness_from_part_name.replace(
                        "mm", "")
                    thickness_from_part_name = thickness_from_part_name.replace(
                        "t", "")
                    thickness_from_part_name = thickness_from_part_name.replace(
                        "_", "")

                    # TODO ValueError: could not convert string to float: 'TM2'
                    if float(thickness_number) != float(
                            thickness_from_part_name):
                        t5.add_issue(
                            entities=[part],
                            status='Error',
                            description='Thickness is different than ' +
                            thickness_from_part_name,
                            thickness=str(thickness_number),
                            thickness_suggest=str(thickness_from_part_name),
                            __key=thickness,
                            __solver=str(solver))

            # Check of contact thickness
            if deck == constants.PAMCRASH and str(
                    params['Contact thickness check']) == 'YES':
                c_thickness_number = part.get_entity_values(
                    solver, [c_thickness])

                if c_thickness_number:
                    c_thickness_number = float(c_thickness_number[c_thickness])
                else:
                    c_thickness_number = 0.0

                if 'CONNECTION' in name:
                    if float(c_thickness_number) != 0.5:
                        t7.add_issue(
                            entities=[part],
                            status='Error',
                            description=
                            'Contact thickness for CONNECTION parts should be 0.5 mm',
                            c_thickness=str(c_thickness_number),
                            c_thickness_suggest=str(0.5),
                            __key=c_thickness,
                            __solver=str(solver))
                        continue

                if c_thickness_number == 0.0:
                    c_thickness_suggest = thickness
                    if c_thickness_number < 0.5:
                        c_thickness_number = 0.5
                    if c_thickness_number > 3:
                        c_thickness_number = 3

                    t7.add_issue(
                        entities=[part],
                        status='Error',
                        description=
                        'Contact thickness is different then thickness ' +
                        thickness_number,
                        c_thickness=str(c_thickness_number),
                        thickness=str(thickness_number),
                        c_thickness_suggest=c_thickness_number,
                        __key=c_thickness,
                        __solver=str(solver))

                else:
                    if c_thickness_number != thickness_number and thickness_number <= 3 and thickness_number >= 0.5:
                        t7.add_issue(
                            entities=[part],
                            status='Warning',
                            description=
                            'Contact thickness should be same as thickness',
                            c_thickness=str(c_thickness_number),
                            thickness=str(thickness_number),
                            c_thickness_suggest=str(thickness_number),
                            __key=c_thickness,
                            __solver=str(solver))

                    if c_thickness_number < 0.5 and thickness_number < 0.5:
                        t7.add_issue(
                            entities=[part],
                            status='Error',
                            description='Contact thickness should be >= 0.5',
                            c_thickness=str(c_thickness_number),
                            thickness=str(thickness_number),
                            c_thickness_suggest='0.5',
                            __key=c_thickness,
                            __solver=str(solver))

                    if c_thickness_number > 3 and thickness_number >= 3.0:
                        t7.add_issue(
                            entities=[part],
                            status='Error',
                            description='Contact thickness should be <= 3',
                            c_thickness=str(c_thickness_number),
                            thickness=str(thickness_number),
                            c_thickness_suggest='3',
                            __key=c_thickness,
                            __solver=str(solver))

    # TODO OSError: [Errno5] Input/output error - can't fix
    print('Properties check for PAMCRASH - SKODA. Number of errors:',
          len(t4.issues) + len(t5.issues) + len(t7.issues))
    return [t4, t5, t6, t7, t8]
Ejemplo n.º 13
0
def exe(entities, params):
    t1 = base.CheckReport(
        'GROUP groups check - 1. wawe - COMBINE GROUP name - components number'
    )
    t2 = base.CheckReport(
        'GROUP groups check - 2. wawe - Screw number in MESH GROUP name vs. COMBINE GROUP name'
    )
    t3 = base.CheckReport(
        'GROUP groups check - 3. wawe - MESH GROUP name vs. COMBINE GROUP name'
    )
    t4 = base.CheckReport(
        'RBODY groups check - 4. wawe - MESH GROUP name - order of components')
    t5 = base.CheckReport(
        'RBODY groups check - 5. wawe - RBODY name and COMBINE GROUP name')
    t6 = base.CheckReport('RBODY groups check - all is OK')

    t1.has_fix = True
    t2.has_fix = True
    t3.has_fix = True
    t4.has_fix = True
    t5.has_fix = True
    t6.has_fix = False

    if entities:
        if type(entities) == list:
            for group in entities:
                if base.IsEntityVisible(
                        group) and 'Scr' in group._name and '-' in group._name:

                    groups = list()
                    groups_name = list()
                    index = 0
                    index_miss = 0
                    index_add = 0
                    index_invert = 0
                    name_group = group._name
                    id_miss = list()
                    id_add = list()
                    ids_from_parts = list()
                    name_list = text_analyse.analyse(text=name_group,
                                                     delimiter='_|-',
                                                     start='Scr',
                                                     special='Scr',
                                                     special_inv=True)
                    number_parts = len(name_list['text_list']) - 1

                    group_obj = rbody_cls(group._id)
                    group_obj.realize()
                    mesh_component_ids = group_obj.mesh_group_content
                    temp = group_obj.combine_group_content

                    if temp != None:
                        for mesh_component_id in mesh_component_ids:
                            ids = mesh_component_id['component_id']
                            group_mesh = mesh_component_id['groups']
                            groups.append(group_mesh)
                            groups_name.append(group_mesh._name)
                            id = ids[0]
                            ids_from_parts.append(id)

                        id = [temp['component_id'][0]]
                        ids_from_parts.extend(id)

                        flag_1_level_error = True
                        flag_2_level_error = True
                        flag_3_level_error = True
                        flag_4_level_error = True
                        flag_5_level_error = True
                        flag_6_level_error = True

                        # component numbers from parts vs. combine group name
                        name_list = text_analyse.analyse(text=name_group,
                                                         delimiter='_|-',
                                                         start='Scr')
                        name_sort = sorted(name_list['text_list'][1:])
                        name_component_sort = sorted(ids_from_parts)
                        if name_component_sort == name_sort:
                            pass
                        else:
                            lenght = len(ids_from_parts)
                            name_info = 'Component number vs. name of COMBINE GROUP: ' + str (name_group) + \
                               ' doesnt match with components' + str (ids_from_parts)
                            t1.add_issue(entities=[group],
                                         status='Error',
                                         description=name_info)
                            flag_1_level_error = False

                        # kontrola cisla scr v group - shoda mesh group a combine group
                        if flag_1_level_error:
                            name_list = text_analyse.analyse(text=name_group,
                                                             delimiter='_|-',
                                                             start='Scr',
                                                             special='Scr',
                                                             special_inv=True)
                            for egroup in groups:
                                name_list_g = text_analyse.analyse(
                                    text=egroup._name,
                                    delimiter='_',
                                    start='Scr',
                                    special='Scr',
                                    special_inv=True,
                                    Exclude='vs')

                                if name_list_g[
                                        'special_list_inv'] == name_list[
                                            'special_list_inv']:
                                    pass
                                else:
                                    name_info = 'Different number of screw in group names. '\
                                       +str( name_list_g['special_list_inv'])+ \
                                       '   '+ str(name_list['special_list_inv'])

                                    t2.add_issue(entities=[group] + groups,
                                                 status='Warning',
                                                 description=name_info)
                                    flag_2_level_error = False

                        # kontrola jmen group - shoda mesh group a combine group
                        if flag_1_level_error and flag_2_level_error:
                            name_list = text_analyse.analyse(text=name_group,
                                                             delimiter='_|-',
                                                             start='Scr')
                            name_sort = sorted(name_list['text_list'][1:])

                            for egroup in groups:
                                name_list_g = text_analyse.analyse(
                                    text=egroup._name,
                                    delimiter='_',
                                    start='Scr',
                                    exclude='vs')
                                name_sort_g = sorted(
                                    name_list_g['text_list'][1:])
                                if name_sort_g == name_sort:
                                    pass
                                else:
                                    lenght = len(ids_from_parts)
                                    name_info = 'Different name COMBINE GROUP: '+ str(name_list['text_list'][1:])+ \
                                     'MESH GROUP:' + str(name_list_g ['text_list'][1:])
                                    t3.add_issue(entities=[group] + [egroup],
                                                 status='Warning',
                                                 description=name_info)
                                    flag_3_level_error = False

                        # kontrola jmen group - order of components
                        if flag_1_level_error and flag_2_level_error and flag_3_level_error:
                            name_list = text_analyse.analyse(text=name_group,
                                                             delimiter='_|-',
                                                             start='Scr')
                            i = 0
                            for egroup in groups:
                                name_list_g = text_analyse.analyse(
                                    text=egroup._name,
                                    delimiter='_',
                                    start='Scr',
                                    exclude='vs')
                                if name_list_g['text_list'][
                                        1] == ids_from_parts[i]:
                                    pass
                                else:
                                    lenght = len(ids_from_parts)
                                    name_info = 'Different name MESH GROUP: ' + str (egroup._name) + \
                                       ' the first component should be: ' + "\""+str (ids_from_parts[i])+"\""
                                    t4.add_issue(entities=[egroup],
                                                 status='Warning',
                                                 description=name_info)
                                    flag_4_level_error = False
                                i = i + 1

                        # kontrola jmen RBODY
                        if flag_1_level_error and flag_2_level_error and flag_3_level_error and flag_4_level_error:
                            ents = base.ReferenceEntities(group)
                            name_rbody = None
                            rbody_ent = None
                            name_info = None
                            for entities_ref in ents:
                                if entities_ref.ansa_type(
                                        constants.PAMCRASH) == 'RBODY':
                                    name_rbody = entities_ref._name
                                    name_info = " "
                                    rbody_ent = entities_ref
                                    if rbody_ent:
                                        if name_group == name_rbody:
                                            pass
                                        else:
                                            name_info = 'Different name COMBINE GROUP: ' + name_group + ' RBODY name: ' + name_rbody
                                            t5.add_issue(
                                                entities=[group, rbody_ent],
                                                status='Warning',
                                                description=name_info)
                                            flag_5_level_error = False
                                    else:
                                        name_info = 'Missing reference RBODY: ' + name_group
                                        t5.add_issue(entities=[group],
                                                     status='Error',
                                                     description=name_info)
                                        flag_5_level_error = False

                            if flag_5_level_error == True:
                                name_info = 'RBODY is OK: ' + name_group
                                t6.add_issue(entities=[group],
                                             status='Warning',
                                             description=name_info)
        else:
            entities = [entities]

    return [t1, t2, t3, t4, t5, t6]