Esempio n. 1
0
 def _read_cord2s(self, data, n):
     """
     (2201,22,10) - the marker for Record 6
     """
     s = Struct(self._endian + b'4i9f')
     nentries = (len(data) - n) // 52
     for i in range(nentries):
         edata = data[n:n + 52]  # 13*4
         out = s.unpack(edata)
         (cid, sixty5, eight, rid, a1, a2, a3, b1, b2, b3, c1, c2, c3) = out
         data_in = [cid, rid, a1, a2, a3, b1, b2, b3, c1, c2, c3]
         if self.is_debug_file:
             self.binary_debug.write('  CORD2S=%s\n' % str(out))
         coord = CORD2S.add_op2_data(data_in)
         self._add_coord_object(coord, allow_overwrites=True)
         n += 52
     self.increase_card_count('CORD2S', nentries)
     return n
Esempio n. 2
0
 def _read_cord2s(self, data, n):
     """
     (2201,22,10) - the marker for Record 6
     """
     s = Struct(b(self._endian + '4i9f'))
     nentries = (len(data) - n) // 52
     for i in range(nentries):
         edata = data[n:n + 52]  # 13*4
         out = s.unpack(edata)
         (cid, sixty5, eight, rid, a1, a2, a3, b1, b2, b3, c1, c2, c3) = out
         data_in = [cid, rid, a1, a2, a3, b1, b2, b3, c1, c2, c3]
         if self.is_debug_file:
             self.binary_debug.write('  CORD2S=%s\n' % str(out))
         coord = CORD2S.add_op2_data(data_in)
         self.add_coord(coord, allow_overwrites=True)
         n += 52
     self._increase_card_count('CORD2S', nentries)
     return n
Esempio n. 3
0
 def _read_cord2s(self, data, n):
     """
     (2201,22,10) - the marker for Record 6
     """
     ntotal = 52 * self.factor # 13*4
     s = Struct(mapfmt(self._endian + b'4i9f', self.size))
     nentries = (len(data) - n) // ntotal
     for unused_i in range(nentries):
         edata = data[n:n + ntotal]
         out = s.unpack(edata)
         (cid, sixty5, eight, rid, a1, a2, a3, b1, b2, b3, c1, c2, c3) = out
         data_in = [cid, rid, a1, a2, a3, b1, b2, b3, c1, c2, c3]
         if self.is_debug_file:
             self.binary_debug.write('  CORD2S=%s\n' % str(out))
         coord = CORD2S.add_op2_data(data_in)
         self._add_coord_object(coord, allow_overwrites=False)
         n += ntotal
     self.increase_card_count('CORD2S', nentries)
     return n
Esempio n. 4
0
 def add_cord2s(self, card, comment=''):
     """adds a CORD2S card"""
     coord = CORD2S.add_card(card, comment=comment)
     self.coords[coord.cid] = coord
     self.n += 1
Esempio n. 5
0
def _add_force(Fg: np.ndarray, dof_map: Dict[Tuple[int, int], int], model: BDF,
               load, offset: int, ndof_per_grid: int, cid: int=0, show_warning: bool=True):
    """adds the FORCE/MOMENT loads to Fg"""
    #cid = load.cid
    nid = load.node
    node_ref = load.node_ref
    ndofi = ndof_per_grid if node_ref.type == 'GRID' else 1
    assert ndofi == 6, f'GRID must have 6 DOF for structural analysis\n{node_ref}'

    if node_ref.cd == cid:
        fglobal = load.mag * load.xyz
    elif node_ref.cd != cid:
        fbasic = load.to_global()
        if show_warning:
            model.log.warning(f'differing cid & cd is not supported; cid={cid} cd={node_ref.cd}')
            show_warning = False
        cd_ref = node_ref.cd_ref
        Tbg = cd_ref.beta()
        fglobal = _force_to_local(cd_ref, fbasic)

        if 0:  # pragma: no cover
            if cd_ref.type[-1] in ['C', 'S']:
                ex = Tbg[0, :]
                ey = Tbg[1, :]
                #ez = Tbg[2, :]
                xyz_local = node_ref.get_position_wrt(model, node_ref.cd)
                if cd_ref.type[-1] == 'C':
                    theta = radians(xyz_local[1])
                    ct = cos(theta)
                    st = sin(theta)
                    T = np.array([
                        [ct, -st, 0.],
                        [st, ct, 0.],
                        [0., 0., 1.],
                    ])
                    Tbg = Tbg @ T
                else:
                    from pyNastran.bdf.cards.coordinate_systems import CORD2S
                    rho, thetad, phid = xyz_local
                    coord = CORD2S.add_ijk(-1, origin=cd_ref.origin, i=ex, j=ey, k=None, rid=0, comment='')
                    beta = coord.beta()
                    Tbg = Tbg @ beta
                    coord.transform_vector_to_local([rho, thetad, phid])
                    #theta = radians(xyz_local[1])
                    #phi = radians(xyz_local[2])
                    #ct = cos(theta)
                    #st = sin(theta)

                    #cp = cos(phi)
                    #sp = sin(phi)

                str(xyz_local)
            else:
                # rectangular
                pass
            Tgb = Tbg.T
            fglobal = Tgb @ fbasic
    else:
        raise NotImplementedError(f'node_ref.cd={node_ref.cd} cid={cid} load:\n{str(load)}')

    for dof in range(3):
        irow = dof_map[(nid, dof+offset)]
        Fg[irow] += fglobal[dof]
    return show_warning
Esempio n. 6
0
 def add_cord2s(self, card, comment=''):
     """adds a CORD2S card"""
     coord = CORD2S.add_card(card, comment=comment)
     self.coords[coord.cid] = coord
     self.n += 1