• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python field_writer_8.print_card_8函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyNastran.bdf.field_writer_8.print_card_8函数的典型用法代码示例。如果您正苦于以下问题:Python print_card_8函数的具体用法?Python print_card_8怎么用?Python print_card_8使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了print_card_8函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: assert_fields

def assert_fields(card1, card2):
    try:
        fields1 = wipe_empty_fields(card1.repr_fields())
        fields2 = wipe_empty_fields(card2.repr_fields())
    except:
        print("card1 = \n%s" % (card1))
        print("card2 = \n%s" % (card2))
        raise

    if len(fields1) != len(fields2):
        msg = ('len(fields1)=%s len(fields2)=%s\n%r\n%r\n%s\n%s'
               % (len(fields1), len(fields2), fields1, fields2,
                  print_card_8(fields1), print_card_8(fields2)))
        raise RuntimeError(msg)

    for (i, field1, field2) in zip(count(), fields1, fields2):
        value1a = print_field(field1)
        value2a = print_field(field2)
        if value1a != value2a:
            value1 = print_field(interpret_value(value1a))
            value2 = print_field(interpret_value(value2a))

            if value1 != value2:
                msg = 'value1 != value2\n'
                msg += ('cardName=%s ID=%s i=%s field1=%r field2=%r value1=%r '
                        'value2=%r\n%r\n%r' % (fields1[0], fields1[1], i,
                                               field1, field2, value1, value2,
                                               fields1, fields2))
                raise RuntimeError(msg)
开发者ID:ClaesFredo,项目名称:pyNastran,代码行数:29,代码来源:compare_card_content.py


示例2: write_card

    def write_card(self, size=8, is_double=False):
        msg = '\n$' + '-' * 80
        msg += '\n$ %s Matrix %s\n' % ('DMI', self.name)
        list_fields = ['DMI', self.name, 0, self.form, self.tin,
                       self.tout, None, self.nRows, self.nCols]
        if size == 8:
            msg += print_card_8(list_fields)
        #elif is_double:
            #msg += print_card_double(list_fields)
        else:
            msg += print_card_16(list_fields)
        #msg += self.print_card(list_fields,size=16,isD=False)

        if self.is_complex():
            for (gci, gcj, reali, imagi) in zip(self.GCi, self.GCj, self.Real, self.Complex):
                list_fields = ['DMI', self.name, gcj, gci, reali, imagi]
                if size == 8:
                    msg += print_card_8(list_fields)
                elif is_double:
                    msg += print_card_double(list_fields)
                else:
                    msg += print_card_16(list_fields)
        else:
            for (gci, gcj, reali) in zip(self.GCi, self.GCj, self.Real):
                list_fields = ['DMI', self.name, gcj, gci, reali]
                if size == 8:
                    msg += print_card_8(list_fields)
                elif is_double:
                    msg += print_card_double(list_fields)
                else:
                    msg += print_card_16(list_fields)
        return msg
开发者ID:ClaesFredo,项目名称:pyNastran,代码行数:32,代码来源:dmig.py


示例3: _write_nodes_symmetric

    def _write_nodes_symmetric(self, outfile, size=8, is_double=False, plane='xz'):
        """
        Writes the NODE-type cards

        Parameters
        ----------
        self : BDF()
            the BDF object

        .. warning :: doesn't consider coordinate systems;
                      it could, but you'd need 20 new coordinate systems
        .. warning :: doesn't mirror SPOINTs, EPOINTs
        """
        if self.spoints:
            msg = []
            msg.append('$SPOINTS\n')
            msg.append(self.spoints.write_card(size, is_double))
            outfile.write(''.join(msg))
        if self.epoints:
            msg = []
            msg.append('$EPOINTS\n')
            msg.append(self.epoints.write_card(size, is_double))
            outfile.write(''.join(msg))

        plane = plane.strip().lower()
        if plane == 'xz':
            iy = 4
        elif plane == 'xy':
            iy = 5
        elif plane == 'yz':
            iy = 3
        else:
            raise NotImplementedError(plane)
        if self.nodes:
            msg = []
            msg.append('$NODES\n')
            if self.gridSet:
                msg.append(self.gridSet.print_card(size))

            nid_offset = max(self.nodes.keys())
            if self.is_long_ids:
                print_card_long = print_card_double if is_double else print_card_16
                for (unused_nid, node) in sorted(iteritems(self.nodes)):
                    repr_fields = node.repr_fields()
                    msg.append(print_card_long(repr_fields))
                    repr_fields = node.repr_fields()
                    # grid, nid, cp, x, y, z
                    repr_fields[1] += nid_offset
                    repr_fields[iy] *= -1.0
                    msg.append(print_card_long(repr_fields))
            else:
                for (unused_nid, node) in sorted(iteritems(self.nodes)):
                    repr_fields = node.repr_fields()
                    msg.append(print_card_8(repr_fields))
                    repr_fields = node.repr_fields()
                    # grid, nid, cp, x, y, z
                    repr_fields[1] += nid_offset
                    repr_fields[iy] *= -1.0
                    msg.append(print_card_8(repr_fields))
            outfile.write(''.join(msg))
开发者ID:abk-ShuaiHaotian,项目名称:pyNastran,代码行数:60,代码来源:bdf_writeMesh.py


示例4: cart3d_to_nastran_filename

def cart3d_to_nastran_filename(cart3d_filename, bdf_filename, log=None, debug=False):
    """
    Converts a Cart3D file to Nastran format.

    Parameters
    ----------
    cart3d_filename : str
        path to the input Cart3D file
    bdf_filename : str
        path to the output BDF file
    log : log / None
        log : a logger object
        None : a log will be defined
    debug : bool
        True/False (used if log is not defined)
    """
    cart3d = Cart3D(log=log, debug=debug)
    cart3d.read_cart3d(cart3d_filename)
    nodes = cart3d.nodes
    elements = cart3d.elements
    regions = cart3d.regions

    #bdf = BDF()
    #bdf.nodes = cart3d.nodes
    #bdf.elements = cart3d.elements
    #bdf.write_bdf(bdf_filename)
    #return
    f = open(bdf_filename, 'wb')
    f.write('CEND\n')
    f.write('BEGIN BULK\n')
    f.write('$Nodes\n')

    i = 0
    nid = 1
    cid = 0
    for node in nodes:
        card = print_card_16(['GRID', nid, cid] + list(node))
        f.write(card)
        nid += 1

    eid = 1
    f.write('$Elements\n')
    for (n1, n2, n3), pid in zip(elements, regions):
        card = print_card_8(['CTRIA3', eid, pid, n1, n2, n3])
        f.write(card)
        eid += 1

    t = 0.1
    E = 1e7
    nu = 0.3
    f.write('$Properties\n')
    for pid in unique(regions):
        mid = pid
        card = print_card_8(['PSHELL', pid, mid, t])
        f.write(card)
        card = print_card_8(['MAT1', mid, E, None, nu])
        f.write(card)
    f.write('ENDDATA\n')
    f.close()
开发者ID:HibernantBear,项目名称:pyNastran,代码行数:59,代码来源:cart3d_to_nastran.py


示例5: stl_to_nastran_filename

def stl_to_nastran_filename(stl_filename, bdf_filename,
                            nnodes_offset=0, nelements_offset=0,
                            pid=100, mid=200,
                            size=8, is_double=False,
                            log=None):
    model = STLReader(log=log)
    model.read_stl(stl_filename)

    nid = nnodes_offset + 1
    cid = None
    load_id = 10

    nodal_normals = model.get_normals_at_nodes(model.elements)

    bdf = open(bdf_filename, 'wb')
    bdf.write('CEND\n')
    #bdf.write('LOAD = %s\n' % load_id)
    bdf.write('BEGIN BULK\n')
    nid2 = 1
    magnitude = 100.

    if size == 8:
        print_card = print_card_8
    elif size == 16:
        if is_double:
            print_card = print_card_16
        else:
            print_card = print_card_double

    for x, y, z in model.nodes:
        card = ['GRID', nid, cid, x, y, z]
        bdf.write(print_card_16(card))

        #nx, ny, nz = nodal_normals[nid2 - 1]
        #card = ['FORCE', load_id, nid, cid, magnitude, nx, ny, nz]
        #bdf.write(print_card_8(card))
        nid += 1
        nid2 += 1

    eid = nelements_offset + 1
    for (n1, n2, n3) in (model.elements + (nnodes_offset + 1)):
        card = ['CTRIA3', eid, pid, n1, n2, n3]
        bdf.write(print_card_8(card))
        eid += 1

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

    E = 1e7
    G = None
    nu = 0.3
    card = ['MAT1', mid, E, G, nu]
    bdf.write(print_card_8(card))

    bdf.write('ENDDATA\n')
    bdf.close()
开发者ID:ClaesFredo,项目名称:pyNastran,代码行数:57,代码来源:stl_to_nastran.py


示例6: write_card

    def write_card(self, size=8, is_double=False):
        """
        .. todo:: support double precision
        """
        msg = '\n$' + '-' * 80
        msg += '\n$ %s Matrix %s\n' % (self.type, self.name)
        list_fields = [self.type, self.name, 0, self.ifo, self.tin,
                       self.tout, self.polar, None, self.ncols]
        if size == 8:
            msg += print_card_8(list_fields)
        else:
            msg += print_card_16(list_fields)

        if self.is_complex():
            if self.is_polar():
                for (GCi, GCj, reali, complexi) in zip(self.GCi, self.GCj, self.Real, self.Complex):
                    magi = sqrt(reali**2 + complexi**2)
                    if reali == 0.0:
                        phasei = 0.0
                    else:
                        phasei = degrees(atan2(complexi, reali))
                    list_fields = [self.type, self.name, GCj[0], GCj[1],
                                   None, GCi[0], GCi[1], magi, phasei]
                    if size == 8:
                        msg += print_card_8(list_fields)
                    elif is_double:
                        msg += print_card_double(list_fields)
                    else:
                        msg += print_card_16(list_fields)
            else:
                for (GCi, GCj, reali, complexi) in zip(self.GCi, self.GCj, self.Real, self.Complex):
                    list_fields = [self.type, self.name, GCj[0], GCj[1],
                                   None, GCi[0], GCi[1], reali, complexi]
                    if size == 8:
                        msg += print_card_8(list_fields)
                    elif is_double:
                        msg += print_card_double(list_fields)
                    else:
                        msg += print_card_16(list_fields)
        else:
            for (GCi, GCj, reali) in zip(self.GCi, self.GCj, self.Real):
                list_fields = [self.type, self.name, GCj[0], GCj[1],
                               None, GCi[0], GCi[1], reali, None]
                if size == 8:
                    msg += print_card_8(list_fields)
                elif is_double:
                    msg += print_card_double(list_fields)
                else:
                    msg += print_card_16(list_fields)
        return msg
开发者ID:FrankNaets,项目名称:pyNastran,代码行数:50,代码来源:dmig.py


示例7: __repr__

    def __repr__(self):
        thru_fields = collapse_thru(self.ids)
        #list_fields = ['SESET', self.seid]

        cards = []
        while 'THRU' in thru_fields:
            ithru = thru_fields.index('THRU')
            card = print_card_8(['SESET', self.seid] +
                                thru_fields[ithru - 1:ithru + 2])
            cards.append(card)
            thru_fields = thru_fields[0:ithru - 1]+thru_fields[ithru + 2:]
        if thru_fields:
            card = print_card_8(['SESET', self.seid] + thru_fields)
            cards.append(card)
        return ''.join(cards)
开发者ID:hurlei,项目名称:pyNastran,代码行数:15,代码来源:bdf_sets.py


示例8: convert_ugrid2d_to_nastran

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')
开发者ID:saullocastro,项目名称:pyNastran,代码行数:48,代码来源:ugrid2d_to_nastran.py


示例9: write_card

 def write_card(self, f, size=8, is_double=False):
     #.. todo:: collapse the IDs
     if self.n:
         spoint = list(self.spoint)
         spoint.sort()
         card = ['SPOINT'] + collapse_thru(spoint)
         f.write(print_card_8(card))
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:7,代码来源:spoint.py


示例10: write_card

    def write_card(self, size=8, is_double=False):
        skin = []
        if self.is_skin:
            skin = ['SKIN']

        # checked in NX 2014 / MSC 2005.1
        return self.comment + print_card_8(['SET1', self.sid] + skin + self.get_ids())
开发者ID:hurlei,项目名称:pyNastran,代码行数:7,代码来源:bdf_sets.py


示例11: write_card

 def write_card(self, bdf_file, size=8):
     card = ['NLPCI', self.nlpci_id, self.Type, self.minalr,
             self.maxalr, self.scale, None, self.desiter, self.mxinc]
     if size == 8:
         bdf_file.write(print_card_8(card))
     else:
         bdf_file.write(print_card_16(card))
开发者ID:hurlei,项目名称:pyNastran,代码行数:7,代码来源:nlpci.py


示例12: write_card

 def write_card(self, f, size=8, is_double=False):
     if self.n:
         card = ['GRDSET', None, self.cp, None, None, None, self.cd, self.seid]
         if size == 8:
             f.write(print_card_8(card))
         else:
             f.write(print_card_16(card))
开发者ID:ClaesFredo,项目名称:pyNastran,代码行数:7,代码来源:grid.py


示例13: write_card

 def write_card(self, f, size=8):
     card = ['SPCADD', self.spc_id] + self.spc_ids
     #print "card = ", card
     if size == 8:
         f.write(print_card_8(card))
     else:
         f.write(print_card_16(card))
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:7,代码来源:spcadd.py


示例14: write_card

 def write_card(self, f, size=8):
     for comp, nodes in iteritems(self.components):
         card = ['SPC1', self.constraint_id, comp] + list(nodes)
         if size == 8:
             f.write(print_card_8(card))
         else:
             f.write(print_card_16(card))
开发者ID:HibernantBear,项目名称:pyNastran,代码行数:7,代码来源:spc1.py


示例15: write_card

 def write_card(self, bdf_file, size=8):
     card = ['SPCADD', self.spc_id] + self.spc_ids
     #print("card = ", card)
     if size == 8:
         bdf_file.write(print_card_8(card))
     else:
         bdf_file.write(print_card_16(card))
开发者ID:saullocastro,项目名称:pyNastran,代码行数:7,代码来源:spcadd.py


示例16: write_card

    def write_card(self, bdf_file, size=8, property_id=None):
        if self.n:
            if property_id is None:
                i = arange(self.n)
            else:
                i = searchsorted(self.property_id, property_id)

            for (pid, mid, area, I1, I2, J, nsm, c1, c2, d1, d2, e1, e2, f1, f2, k1, k2,
                 i12) in zip(self.property_id[i], self.material_id[i],
                    self.area[i], self.I1[i], self.I2[i], self.J[i], self.nsm[i],
                    self.C1[i], self.C2[i], self.D1[i], self.D2[i],
                    self.E1[i], self.E2[i], self.F1[i], self.F2[i],
                    self.K1[i], self.K2[i], self.i12[i]):
                if pid in self._comments:
                    bdf_file.write(self._comments[pid])

                #card = ['PBAR', pid, mid, area, I1, I2, J]
                #c1 = set_blank_if_default(self.c1, 0.0)
                #c2 = set_blank_if_default(self.c2, 0.0)

                #d1 = set_blank_if_default(self.d1, 0.0)
                #d2 = set_blank_if_default(self.d2, 0.0)

                #e1 = set_blank_if_default(self.e1, 0.0)
                #e2 = set_blank_if_default(self.e2, 0.0)

                #f1 = set_blank_if_default(self.f1, 0.0)
                #f2 = set_blank_if_default(self.f2, 0.0)

                #k1 = set_blank_if_default(self.k1, 1e8)
                #k2 = set_blank_if_default(self.k2, 1e8)

                list_fields = ['PBAR', pid, mid, area, I1, I2, J, nsm,
                               None, c1, c2, d1, d2, e1, e2, f1, f2, k1, k2, i12]
                bdf_file.write(print_card_8(list_fields))
开发者ID:hurlei,项目名称:pyNastran,代码行数:35,代码来源:pbar.py


示例17: write_card

 def write_card(self, size=8, is_double=False):
     card = wipe_empty_fields(self.repr_fields())
     if size == 8 or len(card) == 8: # to last node
         msg = self.comment + print_card_8(card)
     else:
         msg = self.comment + print_card_16(card)
     return msg
开发者ID:saullocastro,项目名称:pyNastran,代码行数:7,代码来源:axisymmetric_shells.py


示例18: write_card

 def write_card(self, size=8, is_double=False):
     card = self.raw_fields()
     if size == 8:
         return self.comment + print_card_8(card)
     if is_double:
         return self.comment + print_card_double(card)
     return self.comment + print_card_16(card)
开发者ID:saullocastro,项目名称:pyNastran,代码行数:7,代码来源:loads.py


示例19: write_card

    def write_card(self, f, size=8, property_id=None):
        #print('PBARL.n = %s' % self.n)
        if self.n:
            if property_id is None:
                i = arange(self.n)
            else:
                i = searchsorted(self.property_id, property_id)
            #print('i = %s' % i)
            #cid = [cid if cid != 0 else '' for cid in self.coord_id]

            #group = set_blank_if_default(self.group, 'MSCBMLO')
            #list_fields = ['PBARL', self.pid, self.Mid(), group, self.Type, None,
                           #None, None, None] + self.dim + [self.nsm]

            #self.model.log.debug('*pbarl write pids=%s' % self.property_id)
            for (j, pid, mid, group, Type, nsm) in zip(count(), self.property_id[i], self.material_id[i],
                                                       self.group[i], self.Type[i], self.nsm[i]):
                dim = self.dim[j]
                sgroup = set_blank_if_default(group, 'MSCBMLO')

                list_fields = ['PBARL', pid, mid, group, Type, None,
                               None, None, None] + dim + [nsm]
                if size == 8:
                    f.write(print_card_8(list_fields))
                else:
                    f.write(print_card_16(list_fields))
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:26,代码来源:pbarl.py


示例20: write_card

    def write_card(self, f, size, is_double, coord_id=None):
        assert size in [8, 16], size
        assert is_double in [True, False], is_double

        if self.n:
            #if coord_id is None:
            #i = arange(self.n)
            #else:
                #assert len(unique(coord_id))==len(coord_id), unique(coord_id)
                #i = searchsorted(self.coord_id, coord_id)

            if size == 8:
                print_cardi = print_card_8
            elif is_double:
                print_cardi = print_card_double
            else:
                print_cardi = print_card_16

            for cid, coord in iteritems(self.coords):
                if cid > 0:
                    if coord.type in ['CORD1R', 'CORD1C', 'CORD1S']:
                        card = [coord.type, cid, coord.g1, coord.g2, coord.g3]
                    else:
                        card = [coord.type, cid, coord.rid] + list(coord.e1) + list(coord.e2) + list(coord.e3)
                    f.write(print_card_8(card))
开发者ID:ClaesFredo,项目名称:pyNastran,代码行数:25,代码来源:coord.py



注:本文中的pyNastran.bdf.field_writer_8.print_card_8函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python field_writer_8.set_blank_if_default函数代码示例发布时间:2022-05-25
下一篇:
Python field_writer_16.print_card_16函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap