Esempio n. 1
0
    def test_bdf_utils_02(self):
        msg = 'n 1:10  14:20:2  50:40:-1 e 10 20'
        expected_nodes = np.array(
            [1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
             14, 16, 18, 20,
             40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]
        )
        expected_elements = np.array([10, 20])

        output_dict = parse_patran_syntax_dict(msg, pound_dict=None)
        assert np.array_equal(output_dict['n'], expected_nodes)
        assert np.array_equal(output_dict['e'], expected_elements)


        # messing with the order a bit
        msg = 'n 1:#  e 2:#:4 junk 1 7 12:#:2 3'
        expected_nodes = np.array([1, 2, 3, 4, 5])
        expected_elements = np.array([2, 6, 10, 14])
        expected_junk = np.array([1, 3, 7, 12, 14, 16, 18, 20])
        pound_dict = {
            'n' : 5,
            'e' : 14,
            'junk' : 20.,
        }

        output_dict = parse_patran_syntax_dict(msg, pound_dict=pound_dict)
        assert np.array_equal(output_dict['n'], expected_nodes)
        assert np.array_equal(output_dict['e'], expected_elements)

        error_msg = 'expected equal; A-B=%s; B-A=%s' % (
            np.setdiff1d(expected_junk, output_dict['junk']),
            np.setdiff1d(output_dict['junk'], expected_junk))
        assert np.array_equal(output_dict['junk'], expected_junk), error_msg
Esempio n. 2
0
    def test_bdf_utils_02(self):
        """tests parse_patran_syntax_dict"""
        msg = 'n 1:10  14:20:2  50:40:-1 e 10 20'
        expected_nodes = np.array(
            [1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
             14, 16, 18, 20,
             40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]
        )
        expected_elements = np.array([10, 20])

        output_dict = parse_patran_syntax_dict(msg, pound_dict=None)
        assert np.array_equal(output_dict['n'], expected_nodes)
        assert np.array_equal(output_dict['e'], expected_elements)


        # messing with the order a bit
        msg = 'n 1:#  e 2:#:4 junk 1 7 12:#:2 3'
        expected_nodes = np.array([1, 2, 3, 4, 5])
        expected_elements = np.array([2, 6, 10, 14])
        expected_junk = np.array([1, 3, 7, 12, 14, 16, 18, 20])
        pound_dict = {
            'n' : 5,
            'e' : 14,
            'junk' : 20.,
        }

        output_dict = parse_patran_syntax_dict(msg, pound_dict=pound_dict)
        assert np.array_equal(output_dict['n'], expected_nodes)
        assert np.array_equal(output_dict['e'], expected_elements)

        error_msg = 'expected equal; A-B=%s; B-A=%s' % (
            np.setdiff1d(expected_junk, output_dict['junk']),
            np.setdiff1d(output_dict['junk'], expected_junk))
        assert np.array_equal(output_dict['junk'], expected_junk), error_msg

        msg = write_patran_syntax_dict({'e' : [2, 6, 10, 14]})
        assert msg == 'e 2:14:4', 'msg=%r' % msg

        msg = write_patran_syntax_dict({'e' : [1, 2, 6, 10, 14]})
        assert msg == 'e 1 2 6:14:4', 'msg=%r' % msg

        msg = write_patran_syntax_dict(
            {
                'n' : [1, 2, 6, 10, 14],
                'e' : [1, 2, 6, 10, 14],
             },
        )
        assert msg == 'e 1 2 6:14:4 n 1 2 6:14:4', 'msg=%r' % msg

        out = parse_patran_syntax_dict('')
        assert len(out) == 0, 'out=%s' % out
Esempio n. 3
0
def main():  # pragma: no cover
    bdf = None
    #op2_filename = 'model.op2'
    op2 = read_op2(op2_filename=None,
                   combine=True,
                   log=None,
                   debug=True,
                   debug_file=None,
                   build_dataframe=False,
                   skip_undefined_matrices=True,
                   mode='msc')

    subcases = [1]

    groups = {
        1: 'Elm 403082 565514 403084 552195 552196 553965 552204',
    }
    eid_groups = []
    results = {}
    for key, group in sorted(groups.items()):
        eid_group = parse_patran_syntax_dict(group, pound_dict=None)['Elm']
        eid_groups.append(eid_group)
    del groups

    centroid_file = open('centroid.csv', 'w')
    centroid_file.write('group, subcase, eid_max, maxp, eid_min, minp\n')
    for group_id, eids in enumerate(eid_groups):
        # TODO: speed this up by using the same indices
        for subcase in subcases:
            eid_max, maxp, eid_min, minp = get_centroid_max_min_principal_stress(
                bdf, op2, subcase, eids)
            centroid_file.write('%s, %s, %s, %s, %s, %s\n' %
                                (group, subcase, eid_max, maxp, eid_min, minp))

    cat('centroid.csv')
Esempio n. 4
0
    def test_bdf_utils_03(self):
        """tests parse_patran_syntax_dict"""
        node_sets = "e 1:3 n 2:6:2 Node 10:13 N 15 coord 1:10"
        type_map = {
            'n': 'Node',
            'Node': 'Node',
            'e': 'Element',
            'Elm': 'Element',
            'Element': 'Element',
        }

        data = parse_patran_syntax_dict(node_sets, type_map)
        data_expected = {
            'Element': np.array([1, 2, 3]),
            'Node': np.array([2, 4, 6, 10, 11, 12, 13, 15]),
        }

        data = parse_patran_syntax_dict_map(node_sets, type_map, msg='')
        assert len(data.keys()) == len(
            data_expected.keys()), 'data.keys=%s data_expected.keys=%s' % (
                data.keys(), data_expected.keys())
        for key, value in sorted(data.items()):
            assert key in data_expected, 'cant find key=%r' % key
            value_expected = data_expected[key]
            assert np.array_equal(
                value, value_expected), 'key=%r\nvalue=%r\nexpected=%r' % (
                    key, value, value_expected)
Esempio n. 5
0
def main():
    print('main...')
    bdf = None
    op2_filename = 'model.op2'
    op2 = read_op2(op2_filename=None, combine=True, log=None, debug=True,
                  debug_file=None, build_dataframe=False,
                  skip_undefined_matrices=True, mode='msc')

    subcases = [1]

    groups = {
        1 : 'Elm 403082 565514 403084 552195 552196 553965 552204',
    }
    eid_groups = {}
    results = {}
    for key, group in sorted(groups.items()):
        eid_group = parse_patran_syntax_dict(group, pound_dict=None)['Elm']
        eid_groups.append(eid_group)
    del groups

    centroid_file = open('centroid.csv', 'w')
    centroid_file.write('group, subcase, eid_max, maxp, eid_min, minp\n')
    for group_id, eids in enumerate(eid_groups):
        # TODO: speed this up by using the same indices
        for subcase in subcases:
            eid_max, maxp, eid_min, minp = get_centroid_max_min_principal_stress(bdf, op2, subcase, eids)
            centroid_file.write('%s, %s, %s, %s, %s, %s\n' % (
                group, subcase, eid_max, maxp, eid_min, minp))

    cat('centroid.csv')
Esempio n. 6
0
 def check_patran_syntax_dict(cell, pound=None):
     text = str(cell.text())
     try:
         value = parse_patran_syntax_dict(text)
         cell.setStyleSheet("QLineEdit{background: white;}")
         cell.setToolTip('')
         return value, True
     except (ValueError, SyntaxError, KeyError) as e:
         cell.setStyleSheet("QLineEdit{background: red;}")
         cell.setToolTip(str(e))
         return None, False
Esempio n. 7
0
 def check_patran_syntax_dict(self, cell, pound=None):
     text = str(cell.text())
     try:
         value = parse_patran_syntax_dict(text)
         cell.setStyleSheet("QLineEdit{background: white;}")
         cell.setToolTip('')
         return value, True
     except (ValueError, SyntaxError, KeyError) as e:
         cell.setStyleSheet("QLineEdit{background: red;}")
         cell.setToolTip(str(e))
         return None, False
Esempio n. 8
0
def main():
    """the test case"""
    eids = parse_patran_syntax_dict(' Element 830:84798')['Element']
    eids = find_coplanar_elements(bdf_filename, eids)
Esempio n. 9
0
def main():
    """the test case"""
    eids = parse_patran_syntax_dict(' Element 830:84798')['Element']
    eids = find_coplanar_elements(bdf_filename, eids)