Esempio n. 1
0
def convert_ugrid2d_to_nastran(bdf_filename,
                               nodes,
                               tris,
                               quads,
                               cp=2000,
                               pid=2000,
                               mid=2000,
                               axis_order=None,
                               nid_start=1,
                               eid_start=1,
                               punch=True):
    if axis_order is not None:
        nodes = deepcopy(nodes[:, axis_order])

    with open(bdf_filename, 'wb') as bdf_file:
        if not punch:
            bdf_file.write('CEND\n')
            bdf_file.write('BEGIN BULK\n')

        cp = None
        #card = ['CORD2R', cp, 0] + [0., 0., 0.] + [0., 0., 1.] + [1., 0., 0.]
        #f.write(print_card_8(card))

        nid = nid_start
        for xi, yi, zi in nodes:
            # yes I'm aware...x is the axial distance
            # y/z are the x/y plane
            card = ['GRID', nid, cp, xi, yi, zi]
            bdf_file.write(print_card_8(card))
            nid += 1

        t = 0.1
        card = ['PSHELL', pid, mid, t]
        bdf_file.write(print_card_8(card))

        E = 3.0E7
        G = None
        nu = 0.3
        card = ['MAT1', mid, E, G, nu]
        bdf_file.write(print_card_8(card))

        eid = eid_start
        for n1, n2, n3 in tris + nid_start:
            card = ['CTRIA3', eid, pid, n1, n2, n3]
            bdf_file.write(print_int_card(card))
            eid += 1

        for n1, n2, n3, n5 in quads + nid_start:
            card = ['CQUAD4', eid, pid, n1, n2, n3, n5]
            bdf_file.write(print_int_card(card))
            eid += 1

        if not punch:
            bdf_file.write('ENDDATA\n')
def convert_ugrid2d_to_nastran(bdf_filename, nodes, tris, quads,
                               cp=2000, pid=2000, mid=2000,
                               axis_order=None,
                               nid_start=1, eid_start=1, punch=True):
    if axis_order is not None:
        nodes = deepcopy(nodes[:, axis_order])

    with open(bdf_filename, 'wb') as bdf_file:
        if not punch:
            bdf_file.write('CEND\n')
            bdf_file.write('BEGIN BULK\n')

        cp = None
        #card = ['CORD2R', cp, 0] + [0., 0., 0.] + [0., 0., 1.] + [1., 0., 0.]
        #f.write(print_card_8(card))

        nid = nid_start
        for xi, yi, zi in nodes:
            # yes I'm aware...x is the axial distance
            # y/z are the x/y plane
            card = ['GRID', nid, cp, xi, yi, zi]
            bdf_file.write(print_card_8(card))
            nid += 1


        t = 0.1
        card = ['PSHELL', pid, mid, t]
        bdf_file.write(print_card_8(card))

        E = 3.0E7
        G = None
        nu = 0.3
        card = ['MAT1', mid, E, G, nu]
        bdf_file.write(print_card_8(card))

        eid = eid_start
        for n1, n2, n3 in tris + nid_start:
            card = ['CTRIA3', eid, pid, n1, n2, n3]
            bdf_file.write(print_int_card(card))
            eid += 1

        for n1, n2, n3, n5 in quads + nid_start:
            card = ['CQUAD4', eid, pid, n1, n2, n3, n5]
            bdf_file.write(print_int_card(card))
            eid += 1

        if not punch:
            bdf_file.write('ENDDATA\n')
Esempio n. 3
0
def write_xpoints(cardtype, points, comment=''):
    msg = comment
    lists_fields = compress_xpoints(cardtype, points)
    for list_fields in lists_fields:
        if 'THRU' not in list_fields:
            msg += print_int_card(list_fields)
        else:
            msg += print_card_8(list_fields)
    return msg
Esempio n. 4
0
    def write_card(self, size=8, is_double=False):
        """
        The writer method used by BDF.write_card

        :param size:   unused
        :param is_double: unused
        """
        lists_fields = _get_compressed_xpoints(self.type, self.points)
        msg = self.comment
        for list_fields in lists_fields:
            if 'THRU' not in list_fields:
                msg += print_int_card(list_fields)
            else:
                msg += print_card_8(list_fields)
        return msg
Esempio n. 5
0
    def write_card(self, size=8, is_double=False):
        """
        The writer method used by BDF.write_card

        :param size:   unused
        :param is_double: unused
        """
        lists_fields = _get_compressed_xpoints(self.type, self.points)
        msg = self.comment
        for list_fields in lists_fields:
            if 'THRU' not in list_fields:
                msg += print_int_card(list_fields)
            else:
                msg += print_card_8(list_fields)
        return msg
Esempio n. 6
0
    def write_card(self, size=8, is_double=False):
        """
        The writer method used by BDF.write_card

        :param size:   unused
        :param is_double: unused
        """
        msg = self.comment
        lists_fields = self.repr_fields()
        for list_fields in lists_fields:
            if 'THRU' not in list_fields:
                msg += print_int_card(list_fields)
            else:
                msg += print_card_8(list_fields)
        return msg
Esempio n. 7
0
def write_xpoints(cardtype, points, comment=''):
    """writes SPOINTs/EPOINTs"""
    msg = comment
    if isinstance(points, dict):
        point_ids = []
        for point_id, point in sorted(iteritems(points)):
            point_ids.append(point_id)
            if point.comment:
                msg += point.comment
    else:
        point_ids = points
    lists_fields = compress_xpoints(cardtype, point_ids)
    for list_fields in lists_fields:
        if 'THRU' not in list_fields:
            msg += print_int_card(list_fields)
        else:
            msg += print_card_8(list_fields)
    return msg
Esempio n. 8
0
    def write_card(self, size=8, is_double=False):
        """
        The writer method used by BDF.write_card

        Parameters
        ----------
        size : int; default=8
            unused
        size : bool; default=False
            unused
        """
        msg = self.comment
        lists_fields = self.repr_fields()
        for list_fields in lists_fields:
            if 'THRU' not in list_fields:
                msg += print_int_card(list_fields)
            else:
                msg += print_card_8(list_fields)
        return msg
Esempio n. 9
0
    def write_card(self, size=8, is_double=False):
        """
        The writer method used by BDF.write_card

        Parameters
        ----------
        size : int; default=8
            unused
        is_double : bool; default=False
            unused
        """
        lists_fields = compress_xpoints(self.type, self.points)
        msg = self.comment
        for list_fields in lists_fields:
            if 'THRU' not in list_fields:
                msg += print_int_card(list_fields)
            else:
                msg += print_card_8(list_fields)
        return msg
Esempio n. 10
0
    def write_card(self, size=8, is_double=False):
        """
        The writer method used by BDF.write_card

        Parameters
        ----------
        size : int; default=8
            unused
        size : bool; default=False
            unused
        """
        msg = self.comment
        lists_fields = self.repr_fields()
        for list_fields in lists_fields:
            if 'THRU' not in list_fields:
                msg += print_int_card(list_fields)
            else:
                msg += print_card_8(list_fields)
        return msg