Пример #1
0
 def _read_pload4(self, data, n):  ## inconsistent with DMAP
     """
     PLOAD4(7209,72,299) - the marker for Record 20
     """
     ntotal = 48  # 13*4
     nentries = (len(data) - n) // ntotal
     for i in range(nentries):
         edata = data[n:n + 48]
         #iiffffiiifffi   ssssssssssssssss
         out = unpack('2i 4f 3i 3f', edata)
         if self.is_debug_file:
             self.binary_debug.write('  PLOAD4=%s\n' % str(out))
         (sid, eid, p1, p2, p3, p4, g1, g34, cid, n1, n2, n3) = out
         #s1,s2,s3,s4,s5,s6,s7,s8,L1,L2,L3,L4,L5,L6,L7,L8
         #sdrlA = s1+s2+s3+s4
         #sdrlB = s5+s6+s7+s8
         #line_load_dirA = L1+L2+L3+L4
         #line_load_dirB = L5+L6+L7+L8
         sdrlA = None
         sdrlB = None
         line_load_dirA = None
         line_load_dirB = None
         load = PLOAD4.add_op2_data([
             sid, eid, [p1, p2, p3, p4], g1, g34, cid, [n1, n2, n3], sdrlA,
             sdrlB, line_load_dirA, line_load_dirB
         ])
         self._add_load_object(load)
         n += 48
     self.card_count['PLOAD4'] = nentries
     return n
Пример #2
0
    def _read_pload4_nx(self, data, n):  ## inconsistent with DMAP
        """
        PLOAD4(7209,72,299) - the marker for Record 20

        Word Name Type Description
        1 SID          I Load set identification number
        2 EID          I Element identification number
        3 P(4)        RS Pressures
        7 G1           I Grid point identification number at a corner of the face
        8 G34          I Grid point identification number at a diagonal from G1 or CTETRA corner
        9  CID         I Coordinate system identification number
        10 N(3)       RS Components of a vector coordinate system defined by CID
        """
        ntotal = 48  # 12*4
        nentries = (len(data) - n) // ntotal
        assert (len(data) - n) % ntotal == 0
        loads = []
        for i in range(nentries):
            edata = data[n:n + 48]
            out = unpack('2i 4f 3i 3f', edata)
            if self.is_debug_file:
                self.binary_debug.write('  PLOAD4=%s\n' % str(out))
            (sid, eid, p1, p2, p3, p4, g1, g34, cid, n1, n2, n3) = out

            surf_or_line = None
            line_load_dir = None
            load = PLOAD4.add_op2_data([
                sid, eid, [p1, p2, p3, p4], g1, g34, cid, [n1, n2, n3],
                surf_or_line, line_load_dir
            ])
            load.validate()
            loads.append(load)
            n += 48
        self.card_count['PLOAD4'] = nentries
        return n, loads
Пример #3
0
 def _read_pload4(self, data, n):  ## inconsistent with DMAP
     """
     PLOAD4(7209,72,299) - the marker for Record 20
     """
     #print("reading PLOAD4")
     ntotal = 48  # 13*4
     nentries = (len(data) - n) // ntotal
     for i in range(nentries):
         edata = data[n:n + 48]
                      #iiffffiiifffi   ssssssssssssssss
         out = unpack('2i4f3i3f', edata)
         if self.is_debug_file:
             self.binary_debug.write('  PLOAD4=%s\n' % str(out))
         (sid, eid, p1, p2, p3, p4, g1, g34, cid, n1, n2, n3) = out
         #s1,s2,s3,s4,s5,s6,s7,s8,L1,L2,L3,L4,L5,L6,L7,L8
         #sdrlA = s1+s2+s3+s4
         #sdrlB = s5+s6+s7+s8
         #ldirA = L1+L2+L3+L4
         #ldirB = L5+L6+L7+L8
         sdrlA = None
         sdrlB = None
         ldirA = None
         ldirB = None
         load = PLOAD4.add_op2_data(
             [sid, eid, [p1, p2, p3, p4], g1, g34,
              cid, [n1, n2, n3], sdrlA, sdrlB, ldirA, ldirB])
         self.add_load(load)
         n += 48
     self.card_count['PLOAD4'] = nentries
     return n
Пример #4
0
    def _read_pload4_msc(self, data, n):  ## inconsistent with DMAP
        """
        PLOAD4(7209,72,299) - the marker for Record 20

        Word Name Type Description
        1 SID          I Load set identification number
        2 EID          I Element identification number
        3 P(4)        RS Pressures
        7 G1           I Grid point identification number at a corner of the face
        8 G34          I Grid point identification number at a diagonal from G1 or CTETRA corner
        9  CID         I Coordinate system identification number
        10 N(3)       RS Components of a vector coordinate system defined by CID
        13 SDRL(2) CHAR4 Load set on element SURF or LINE
        15 LDIR(2) CHAR4 Load direction
        """
        ntotal = 64 * self.factor  # 16*4
        nentries = (len(data) - n) // ntotal
        assert (len(data) - n) % ntotal == 0
        loads = []
        if self.size == 4:
            s = Struct(self._endian + b'2i 4f 3i 3f 8s 8s')
        else:
            s = Struct(self._endian + b'2q 4d 3q 3d 16s 16s')

        for unused_i in range(nentries):
            edata = data[n:n + ntotal]
            out = s.unpack(edata)
            if self.is_debug_file:
                self.binary_debug.write('  PLOAD4=%s\n' % str(out))
            (sid, eid, p1, p2, p3, p4, g1, g34, cid, n1, n2, n3, surf_or_line,
             line_load_dir) = out

            surf_or_line = surf_or_line.rstrip().decode('latin1')
            line_load_dir = line_load_dir.rstrip().decode('latin1')
            if line_load_dir == '':
                # TODO: not 100%
                line_load_dir = 'NORM'

            # forces NX pload4 function to get called if it should be
            assert surf_or_line in ['SURF', 'LINE']
            assert line_load_dir in ['LINE', 'X', 'Y', 'Z', 'TANG', 'NORM'
                                     ], 'line_load_dir=%r' % line_load_dir

            load = PLOAD4.add_op2_data([
                sid, eid, [p1, p2, p3, p4], g1, g34, cid, [n1, n2, n3],
                surf_or_line, line_load_dir
            ])
            load.validate()
            loads.append(load)
            n += ntotal
        self.card_count['PLOAD4'] = nentries
        return n, loads
Пример #5
0
def _mirror_loads(model, nid_offset=0, eid_offset=0):
    """
    Mirrors the loads

    Considers:
     - PLOAD4
        - no coordinate systems (assumes cid=0)

    """
    for unused_load_id, loads in model.loads.items():
        for load in loads:
            loads_new = []
            load_type = load.type
            if load_type == 'PLOAD4':
                g1 = None
                g34 = None
                if load.g1 is not None:
                    g1 = load.g1 + nid_offset
                if load.g34 is not None:
                    g34 = load.g34 + nid_offset

                eids = [eid + eid_offset for eid in load.eids]
                load2 = PLOAD4(load.sid,
                               eids,
                               load.pressures,
                               g1,
                               g34,
                               cid=load.cid,
                               nvector=load.nvector,
                               surf_or_line=load.surf_or_line,
                               line_load_dir=load.line_load_dir,
                               comment='')
                loads_new.append(load)
            else:  # pragma: no cover
                model.log.warning('skipping:\n%s' % load.rstrip())
        if loads_new:
            loads += loads_new
Пример #6
0
def _mirror_loads(model: BDF, nid_offset: int = 0, eid_offset: int = 0):
    """
    Mirrors the loads.  A mirrored force acts in the same direction.

    Considers:
     - PLOAD4
        - no coordinate systems (assumes cid=0)
     - FORCE, FORCE1, FORCE2, MOMENT, MOMENT1, MOMENT2
     - PLOAD, PLOAD2
     - TEMP, QVOL, QHBDY, QBDY1, QBDY2, QBDY3

    """
    for unused_load_id, loads in model.loads.items():
        for load in loads:
            loads_new = []
            load_type = load.type
            if load_type == 'PLOAD4':
                g1 = None
                g34 = None
                if load.g1 is not None:
                    g1 = load.g1 + nid_offset
                if load.g34 is not None:
                    g34 = load.g34 + nid_offset

                eids = [eid + eid_offset for eid in load.eids]
                load = PLOAD4(load.sid,
                              eids,
                              load.pressures,
                              g1,
                              g34,
                              cid=load.cid,
                              nvector=load.nvector,
                              surf_or_line=load.surf_or_line,
                              line_load_dir=load.line_load_dir,
                              comment='')
                loads_new.append(load)

            elif load_type == 'FORCE':
                load = FORCE(load.sid,
                             load.node + nid_offset,
                             load.mag,
                             load.xyz,
                             cid=load.cid,
                             comment='')
                loads_new.append(load)
            elif load_type == 'FORCE1':
                load = FORCE1(load.sid,
                              load.node + nid_offset,
                              load.mag,
                              load.g1 + nid_offset,
                              load.g2 + nid_offset,
                              comment='')
                loads_new.append(load)
            elif load_type == 'FORCE2':
                load = FORCE2(load.sid,
                              load.node + nid_offset,
                              load.mag,
                              load.g1 + nid_offset,
                              load.g2 + nid_offset,
                              load.g3 + nid_offset,
                              load.g4 + nid_offset,
                              comment='')
                loads_new.append(load)

            elif load_type == 'MOMENT':
                load = MOMENT(load.sid,
                              load.node + nid_offset,
                              load.mag,
                              load.xyz,
                              cid=load.cid,
                              comment='')
                loads_new.append(load)
            elif load_type == 'MOMENT1':
                load = MOMENT1(load.sid,
                               load.node + nid_offset,
                               load.mag,
                               load.g1 + nid_offset,
                               load.g2 + nid_offset,
                               comment='')
                loads_new.append(load)
            elif load_type == 'MOMENT2':
                load = MOMENT2(load.sid,
                               load.node + nid_offset,
                               load.mag,
                               load.g1 + nid_offset,
                               load.g2 + nid_offset,
                               load.g3 + nid_offset,
                               load.g4 + nid_offset,
                               comment='')
                loads_new.append(load)

            elif load_type == 'PLOAD':
                nodes = [nid + nid_offset for nid in load.nodes]
                load = PLOAD(load.sid, load.pressure, nodes, comment='')
                loads_new.append(load)
            elif load_type == 'PLOAD2':
                eids = [eid + eid_offset for eid in load.eids]
                load = PLOAD2(load.sid, load.pressure, eids, comment='')
                loads_new.append(load)

            elif load_type == 'QVOL':
                elements = [eid + eid_offset for eid in load.elements]
                load = QVOL(load.sid, load.qvol,
                            nid_offset + load.control_point, elements)
                loads_new.append(load)
            elif load_type == 'QHBDY':
                grids = [nid + nid_offset for nid in load.grids]
                load = QHBDY(load.sid, load.flag, load.q0, grids, af=load.af)
                loads_new.append(load)
            elif load_type == 'QBDY1':
                eids = [eid + eid_offset for eid in load.eids]
                load = QBDY1(load.sid, load.qflux, eids)
                loads_new.append(load)
            elif load_type == 'QBDY2':
                load = QBDY2(load.sid,
                             load.eid + eid_offset,
                             load.qfluxs,
                             comment='')
                loads_new.append(load)
            elif load_type == 'QBDY3':
                eids = [eid + eid_offset for eid in load.eids]
                load = QBDY3(load.sid, load.q0, load.cntrlnd + nid_offset,
                             eids)
                loads_new.append(load)

            elif load_type == 'TEMP':
                temperatures = {}
                for nid, temp in load.temperatures.items():
                    temperatures[nid + nid_offset] = temp
                load = TEMP(load.sid, temperatures)
                loads_new.append(load)
            elif load_type == 'GRAV':
                pass
            else:  # pragma: no cover
                model.log.warning('skipping:\n%s' % load.rstrip())
        if loads_new:
            loads += loads_new