コード例 #1
0
    def test_quad_180_01(self):
        r"""
        Identify a 180+ degree quad

        y
        ^         4
        |       / |
        |     /   |
        |   /     |
        | /       |
        /         |
        1------2  |----> x
                \ |
                 \|
                  3
        """
        msg = ('CEND\n'
               'BEGIN BULK\n'
               'GRID,1,,0.,0.,0.\n'
               'GRID,2,,1.,0.,0.\n'
               'GRID,3,,2.,-1.,0.\n'
               'GRID,4,,2., 1.,0.\n'
               'CQUAD4,100,1, 1,2,3,4\n'
               'PSHELL,1,1,0.1\n'
               'MAT1,1,3.0,, 0.3\n'
               'ENDDATA')
        bdf_filename = 'cquad4.bdf'
        with codec_open(bdf_filename, 'w') as bdf_file:
            bdf_file.write(msg)

        model = read_bdf(bdf_filename, log=log, xref=True)
        xyz_cid0 = model.get_xyz_in_coord(cid=0, fdtype='float32')
        nid_map = {}
        for i, (nid, node) in enumerate(sorted(iteritems(model.nodes))):
            #xyz = node.get_position()
            #xyz_cid0[i, :] = xyz
            nid_map[nid] = i
        eids_to_delete = get_bad_shells(model,
                                        xyz_cid0,
                                        nid_map,
                                        max_theta=180.,
                                        max_skew=1000.,
                                        max_aspect_ratio=1000.)
        assert eids_to_delete == [100], eids_to_delete
        os.remove(bdf_filename)
コード例 #2
0
ファイル: test_mesh_utils.py プロジェクト: hurlei/pyNastran
    def test_quad_180_01(self):
        r"""
        Identify a 180+ degree quad

        y
        ^         4
        |       / |
        |     /   |
        |   /     |
        | /       |
        /         |
        1------2  |----> x
                \ |
                 \|
                  3
        """
        msg = (
            'CEND\n'
            'BEGIN BULK\n'
            'GRID,1,,0.,0.,0.\n'
            'GRID,2,,1.,0.,0.\n'
            'GRID,3,,2.,-1.,0.\n'
            'GRID,4,,2., 1.,0.\n'

            'CQUAD4,100,1, 1,2,3,4\n'
            'PSHELL,1,1,0.1\n'
            'MAT1,1,3.0,, 0.3\n'
            'ENDDATA'
        )
        bdf_filename = 'cquad4.bdf'
        with codec_open(bdf_filename, 'w') as bdf_file:
            bdf_file.write(msg)

        model = read_bdf(bdf_filename, xref=True)
        xyz_cid0 = model.get_xyz_in_coord(cid=0, dtype='float32')
        nid_map = {}
        for i, (nid, node) in enumerate(sorted(iteritems(model.nodes))):
            #xyz = node.get_position()
            #xyz_cid0[i, :] = xyz
            nid_map[nid] = i
        eids_to_delete = get_bad_shells(model, xyz_cid0, nid_map, max_theta=180.,
                                        max_skew=1000., max_aspect_ratio=1000.)
        assert eids_to_delete == [100], eids_to_delete
        os.remove(bdf_filename)
コード例 #3
0
    def test_quad_quality_02(self):
        r"""
        Identify bad quads

        EID = 101 (skew)
        y
        ^         4
        |       /  \
        |     /       \
        |   /               \
        | /                      \
        /                             \
        1------------------------------5-> x
          \                     /
             \          /
                  3

        EID = 102 (aspect ratio)
        y
        ^         8--------------------------6
        |       /                           /
        |     /                            /
        |   /                             /
        | /                              /
        /                               /
        1------------------------------5-> x

        EID = 103 (taper ratio)
        y
        ^         8--------------7
        |       /                 \
        |     /                    \
        |   /                       \
        | /                          \
        /                             \
        1------------------------------5-> x

        """
        msg = (
            'CEND\n'
            'BEGIN BULK\n'
            'GRID,1,,0.,   0.,0.\n'
            #'GRID,2,,1.,   0.,0.\n'
            'GRID,3,,2.,  -1.,0.\n'
            'GRID,4,,2.,   1.,0.\n'

            # shift x by 200
            'GRID,5,,200., 0.,0.\n'

            # shifted by 30 to match dx of GRID 8
            #raised up to match 7,8 height
            'GRID,6,,245., 100.,0.\n'

            # raised up to prevent large thetas
            # brought in to cause a taper
            'GRID,7,,55.,  100.,0.\n'
            'GRID,8,,45.,  100.,0.\n'

            #'CQUAD4,100,1, 1,2,3,4\n'
            'CQUAD4,101,1, 1,3,5,4\n'
            'CQUAD4,102,1, 1,5,6,8\n'
            'CQUAD4,103,1, 1,5,7,8\n'
            'PSHELL,1,1,0.1\n'
            'MAT1,1,3.0,, 0.3\n'
            'ENDDATA'
        )
        log = SimpleLogger(level='error')
        bdf_filename = 'cquad4.bdf'
        with open(bdf_filename, 'w') as bdf_file:
            bdf_file.write(msg)

        model = read_bdf(bdf_filename, log=log, xref=True)
        xyz_cid0 = model.get_xyz_in_coord(cid=0, fdtype='float32')
        nid_map = {}
        for i, nid in enumerate(sorted(model.nodes.keys())):
            nid_map[nid] = i


        max_skew_active = 70.
        max_aspect_ratio_active = 50.
        max_taper_ratio_active = 2.5

        min_theta = 0.1
        max_theta = 1000.
        max_skew = 1000.
        max_aspect_ratio = 1000.
        max_taper_ratio = 1000.

        #log = SimpleLogger(level='debug')
        #model.log = log

        # max skew
        eids_to_delete = get_bad_shells(
            model, xyz_cid0, nid_map,
            min_theta=min_theta,
            max_theta=max_theta,
            max_skew=max_skew_active,
            max_aspect_ratio=max_aspect_ratio,
            max_taper_ratio=max_taper_ratio)
        assert eids_to_delete == [101], eids_to_delete

        # aspect ratio
        eids_to_delete = get_bad_shells(
            model, xyz_cid0, nid_map,
            min_theta=min_theta,
            max_theta=max_theta,
            max_skew=max_skew,
            max_aspect_ratio=max_aspect_ratio_active,
            max_taper_ratio=max_taper_ratio,
        )
        assert eids_to_delete == [101], eids_to_delete

        # taper ratio
        eids_to_delete = get_bad_shells(
            model, xyz_cid0, nid_map,
            min_theta=min_theta,
            max_theta=max_theta,
            max_skew=max_skew,
            max_aspect_ratio=max_aspect_ratio,
            max_taper_ratio=max_taper_ratio_active,
        )
        assert eids_to_delete == [103], eids_to_delete
        os.remove(bdf_filename)
コード例 #4
0
    def test_quad_180_01(self):
        r"""
        Identify a 180+ degree quad

        EID = 100 (max_theta > 180)
        y
        ^         4
        |       / |
        |     /   |
        |   /     |
        | /       |
        /         |
        1------2  |----> x
                \ |
                 \|
                  3


        """
        msg = (
            'CEND\n'
            'BEGIN BULK\n'
            'GRID,1,,0.,   0.,0.\n'
            'GRID,2,,1.,   0.,0.\n'
            'GRID,3,,2.,  -1.,0.\n'
            'GRID,4,,2.,   1.,0.\n'
            'CQUAD4,100,1, 1,2,3,4\n'
            'PSHELL,1,1,0.1\n'
            'MAT1,1,3.0,, 0.3\n'
            'ENDDATA'
        )
        log = SimpleLogger(level='error')
        bdf_filename = 'cquad4.bdf'
        with open(bdf_filename, 'w') as bdf_file:
            bdf_file.write(msg)

        model = read_bdf(bdf_filename, log=log, xref=True)
        xyz_cid0 = model.get_xyz_in_coord(cid=0, fdtype='float32')
        nid_map = {}
        for i, nid in enumerate(sorted(model.nodes.keys())):
            nid_map[nid] = i


        max_theta_active = 180.

        min_theta = 0.1
        max_skew = 1000.
        max_aspect_ratio = 1000.
        max_taper_ratio = 1000.

        # max theta
        eids_to_delete = get_bad_shells(
            model, xyz_cid0, nid_map,
            min_theta=min_theta,
            max_theta=max_theta_active,
            max_skew=max_skew,
            max_aspect_ratio=max_aspect_ratio,
            max_taper_ratio=max_taper_ratio)
        assert eids_to_delete == [100], eids_to_delete

        delete_bad_shells(
            model,
            min_theta=min_theta,
            max_theta=max_theta_active,
            max_skew=max_skew,
            max_aspect_ratio=max_aspect_ratio,
            max_taper_ratio=max_taper_ratio)

        assert len(model.elements) == 0, model.elements
        os.remove(bdf_filename)
コード例 #5
0
    def test_tri_quality_01(self):
        r"""
        Identify a 180+ degree quad

        EID = 100 (perfect)
        y
        ^     3
        |    / \
        |   /   \
        |  /     \
        | /       \
        |/         \
        1-----------2----> x

        EID = 101 (???)
        y
        ^     6
        |    /   \
        |   /       \
        |  /           \
        | /               \
        |/                   \
        4----------------------5----> x

        """
        msg = (
            'CEND\n'
            'BEGIN BULK\n'
            'GRID,1,,0.,   0.,0.\n'
            'GRID,2,,1.,   0.,0.\n'
            'GRID,3,,0.5,  1.,0.\n'
            'CTRIA3,100,1, 1,2,3\n'

            'GRID,4,,  0.,   0.,5.\n'
            'GRID,5,,300.,  0.,5.\n'
            'GRID,6,, 0.5,  1.,5.\n'
            'CTRIA3,101,1, 4,5,6\n'

            'PSHELL,1,1,0.1\n'
            'MAT1,1,3.0,, 0.3\n'
            'ENDDATA'
        )
        log = SimpleLogger(level='error')
        bdf_filename = 'cquad4.bdf'
        with open(bdf_filename, 'w') as bdf_file:
            bdf_file.write(msg)

        model = read_bdf(bdf_filename, log=log, xref=True)
        xyz_cid0 = model.get_xyz_in_coord(cid=0, fdtype='float32')
        nid_map = {}
        for i, nid in enumerate(sorted(model.nodes.keys())):
            nid_map[nid] = i


        max_skew_active = 70.
        max_theta_active = 115.
        max_aspect_ratio_active = 15.

        min_theta = 0.1
        max_theta = 1000.
        max_skew = 1000.
        max_aspect_ratio = 1000.

        # max theta
        eids_to_delete = get_bad_shells(
            model, xyz_cid0, nid_map,
            min_theta=min_theta,
            max_theta=max_theta_active,
            max_skew=max_skew,
            max_aspect_ratio=max_aspect_ratio,
        )
        assert eids_to_delete == [101], eids_to_delete

        # max skew
        eids_to_delete = get_bad_shells(
            model, xyz_cid0, nid_map,
            min_theta=min_theta,
            max_theta=max_theta,
            max_skew=max_skew_active,
            max_aspect_ratio=max_aspect_ratio,
        )
        assert eids_to_delete == [101], eids_to_delete

        # aspect ratio
        eids_to_delete = get_bad_shells(
            model, xyz_cid0, nid_map,
            min_theta=min_theta,
            max_theta=max_theta,
            max_skew=max_skew,
            max_aspect_ratio=max_aspect_ratio_active,
        )
        assert eids_to_delete == [101], eids_to_delete

        delete_bad_shells(
            model,
            min_theta=min_theta,
            max_theta=max_theta_active,
            max_skew=max_skew,
            max_aspect_ratio=max_aspect_ratio,
        )
        assert eids_to_delete == [101], eids_to_delete