示例#1
0
def test_rdcord2cards2():
    s1 = """
$1111111222222223333333344444444555555556666666677777777888888889999999900000000
CORD2R       501       0   300.0    4.0 -10.0000  .56000 .200000   -10.7+
+       310.0000     4.0   -11.7
"""

    s2 = """
$1111111222222223333333344444444555555556666666677777777888888889999999900000000
CORD2R       501           300.0    4.0 -10.0000  .56000 .200000   -10.7+
+       310.0000     4.0   -11.7
"""

    with StringIO(s1) as f:
        cords1 = nastran.rdcord2cards(f)

    with StringIO(s2) as f:
        cords2 = nastran.rdcord2cards(f)

    assert np.all(cords1[501] == cords2[501])
示例#2
0
def test_rdcord2cards_errors():
    strs = [
        """
    $1111111222222223333333344444444555555556666666677777777888888889999999900000000
    CORD2R       501           300.0    4.0 -10.0000  .56000 .200000   -10.7+
    +       310.0000     4.0   -11.7    1.0
    """,
        """
    $1111111222222223333333344444444555555556666666677777777888888889999999900000000
    CORD2R       501           300.0    4.0 -10.0000  .56000 .200000   -10.7+
    +       310.0a00     4.0   -11.7
    """,
    ]

    for i, s in enumerate(strs):
        with StringIO(s) as f:
            try:
                nastran.rdcord2cards(f)
            except ValueError as e:
                if i == 0:
                    assert e.args[0].startswith("expected 12")
                else:
                    assert e.args[0].startswith("could not convert")
示例#3
0
def test_rdcord2cards():
    cylcoord = np.array([[50, 2, 0], [0, 0, 0], [1, 0, 0], [0, 1, 0]])
    sphcoord = np.array([[51, 3, 0], [0, 0, 0], [0, 1, 0], [0, 0, 1]])

    uset = n2p.addgrid(
        None,
        [100, 200, 300],
        "b",
        [0, cylcoord, sphcoord],
        [[5, 10, 15], [32, 90, 10], [50, 90, 90]],
        [0, cylcoord, sphcoord],
    )

    with StringIO() as f:
        nastran.uset2bulk(f, uset)
        cords = nastran.rdcord2cards(f)
        u, c = nastran.bulk2uset(f)

    assert len(cords) == len(c)
    for k, v in cords.items():
        assert np.allclose(c[k], v)
示例#4
0
def test_asm2uset():
    asm1 = """
$ SE101 ASSEMBLY FILE FOR RESIDUAL RUN...INCLUDE IN BULK DATA
$
SEBULK       101  EXTOP4          MANUAL                     101
SECONCT      101       0              NO
               3       3      11      11      19      19      27      27
$
$ COORDINATE SYSTEM DATA
$
$ Coordinate 10:
CORD2R*               10               0  0.00000000e+00  0.00000000e+00*
*         0.00000000e+00  1.00000000e+00  0.00000000e+00  0.00000000e+00*
*         0.00000000e+00  1.00000000e+00  0.00000000e+00
$
$ BOUNDARY GRID DATA
$
GRID*                  3               0    600.00000000      0.00000000
*           300.00000000               0
GRID*                 11               0    600.00000000    300.00000000
*           300.00000000              10
GRID*                 19               0    600.00000000    300.00000000
*             0.00000000               0
GRID*                 27               0    600.00000000      0.00000000
*             0.00000000               0
$
SECONCT      101       0              NO
         9900101    THRU 9900122 9900101    THRU 9900122
$
SPOINT   9900101    THRU 9900122
"""
    with StringIO(asm1) as f:
        uset1, cord1, bset1 = nastran.asm2uset(f)
        cords1 = nastran.rdcord2cards(f)

    # make the uset manually for testing:
    rng = range(9900101, 9900123)
    dof = [[3, 123456], [11, 123456], [19, 123456], [27, 123456]] + [
        [i, 0] for i in rng
    ]
    nasset = np.zeros(4 + 22, np.int64)
    nasset[:4] = n2p.mkusetmask("b")
    nasset[4:] = n2p.mkusetmask("q")
    xyz = np.array(
        [
            [600.0, 0.0, 300.0],
            [600.0, 300.0, 300.0],
            [600.0, 300.0, 0.0],
            [600.0, 0.0, 0.0],
        ]
        + [[0.0, 0.0, 0.0] for i in rng]
    )

    uset1_man = n2p.make_uset(dof=dof, nasset=nasset, xyz=xyz)

    # fix up grid 11 coords:
    uset1_man.loc[(11, 2), "x"] = 10
    uset1_man.loc[(11, 4):(11, 6), "x":"z"] = [
        [0.0, 0.0, 1.0],
        [1.0, 0.0, 0.0],
        [0.0, 1.0, 0.0],
    ]
    # assert uset1.equals(uset1_man)
    assert np.allclose(uset1.reset_index(), uset1_man.reset_index())
    assert (bset1 == n2p.mksetpv(uset1, "a", "b")).all()

    assert len(cords1) == len(cord1)
    for k, v in cords1.items():
        assert np.allclose(cord1[k], v)

    asm2 = """
$ SE101 ASSEMBLY FILE FOR RESIDUAL RUN...INCLUDE IN BULK DATA
$
$1111111222222223333333344444444555555556666666677777777888888889999999900000000
SEBULK       101  EXTOP4          MANUAL                     101
SECONCT      101       0              NO
               3       3     110     110      19      19      27      27
$
$ COORDINATE SYSTEM DATA
$
$ Coordinate 10:
CORD2R*               10               0  0.00000000e+00  0.00000000e+00*
*         0.00000000e+00  1.00000000e+00  0.00000000e+00  0.00000000e+00*
*         0.00000000e+00  1.00000000e+00  0.00000000e+00
$
$ BOUNDARY GRID DATA
$
GRID*                  3               0    600.00000000      0.00000000
*           300.00000000               0
GRID*                 19               0    600.00000000    300.00000000
*             0.00000000               0
GRID*                 27               0    600.00000000      0.00000000
*             0.00000000               0
$
SPOINT   110
"""

    with StringIO(asm2) as f:
        uset2, cord2, bset2 = nastran.asm2uset(f)
        cords2 = nastran.rdcord2cards(f)

    # make the uset manually for testing:
    dof = [[3, 123456], [110, 0], [19, 123456], [27, 123456]]
    nasset = np.zeros(4, np.int64)
    nasset[:] = n2p.mkusetmask("b")
    nasset[1] = n2p.mkusetmask("q")
    xyz = np.array(
        [[600.0, 0.0, 300.0], [0.0, 0.0, 0.0], [600.0, 300.0, 0.0], [600.0, 0.0, 0.0]]
    )

    uset2_man = n2p.make_uset(dof=dof, nasset=nasset, xyz=xyz)
    # assert uset2.equals(uset2_man)
    assert np.allclose(uset2.reset_index(), uset2_man.reset_index())
    assert (bset2 == n2p.mksetpv(uset2, "a", "b")).all()

    assert len(cords2) == len(cord2)
    for k, v in cords2.items():
        assert np.allclose(cord2[k], v)