Ejemplo n.º 1
0
    def OES_Rod1_alt(self):
        """
        genericStressReader - works on CROD_1, CELAS2_12
        stress & strain
        format_code=1 sort_code=1 (eid,axial,axial,torsion,torsion)
        """
        dt = self.nonlinear_factor
        (format1, extract) = self.getOUG_FormatStart()
        nTotal = 12
        format1 += '4f'

        is_magnitude_phase = self.is_magnitude_phase()

        n = 0
        nEntries = len(self.data) // nTotal
        for i in range(nEntries):
            eData = self.data[n:n + nTotal]
            (eid, axialReal, axialImag, torsionReal,
             torsionImag) = unpack(format1, eData)

            if is_magnitude_phase:
                (axial) = polar_to_real_imag(axialReal, axialImag)
                (torsion) = polar_to_real_imag(torsionReal, torsionImag)
            else:
                axial = complex(axialReal, axialImag)
                torsion = complex(torsionReal, torsionImag)

            #print "out = ",out
            eid = extract(eid, dt)
            self.obj.add_new_eid(dt, eid, axial, torsion)
            n += nTotal
        self.data = self.data[n:]
Ejemplo n.º 2
0
    def OES_CBUSH1D_40_alt(self):
        dt = self.nonlinear_factor
        (format1, extract) = self.getOUG_FormatStart()
        is_magnitude_phase = self.is_magnitude_phase()

        assert self.num_wide == 9, "num_wide=%s not 9" % (self.num_wide)
        nTotal = 36  # 4*9
        format1 += '8f'

        while len(self.data) >= nTotal:
            eData = self.data[0:nTotal]
            self.data = self.data[nTotal:]

            out = unpack(format1, eData)  # num_wide=25
            (eid, fer, uer, aor, aer, fei, uei, aoi, aei) = out
            eid = extract(eid, dt)

            if is_magnitude_phase:
                fe = polar_to_real_imag(fer, fei)
                ue = polar_to_real_imag(uer, uei)
                ao = polar_to_real_imag(aor, aoi)
                ae = polar_to_real_imag(aer, aei)
            else:
                fe = complex(fer, fei)
                ue = complex(uer, uei)
                ao = complex(aor, aoi)
                ae = complex(aer, aei)

            self.obj.add_new_eid(self.element_type, dt, eid, fe, ue, ao, ae)
Ejemplo n.º 3
0
    def OEF_Rod_alt(self):  # 1-CROD, 3-CTUBE, 10-CONROD
        #device_code = self.device_code
        dt = self.nonlinear_factor
        (format1, extract) = self.getOEF_FormatStart()
        format1 += '4f'

        is_magnitude_phase = self.is_magnitude_phase()

        while len(self.data) >= 20:  # 5*4
            eData = self.data[0:20]
            self.data = self.data[20:]
            #print "len(data) = ",len(eData)

            out = unpack(format1, eData)
            (eid, axialReal, torqueReal, axialImag, torqueImag) = out

            if is_magnitude_phase:
                (axial) = polar_to_real_imag(axialReal, axialImag)
                (torque) = polar_to_real_imag(torqueReal, torqueImag)
            else:
                axial = complex(axialReal, axialImag)
                torque = complex(torqueReal, torqueImag)
            eid2 = extract(eid, dt)
            #print "eType=%s" %(eType)

            dataIn = [eid2, axial, torque]
            #print "%s" %(self.get_element_type(self.element_type)),dataIn
            #eid = self.obj.add_new_eid(out)
            self.obj.add(dt, dataIn)
Ejemplo n.º 4
0
    def OES_CBUSH1D_40_alt(self):
        dt = self.nonlinear_factor
        (format1, extract) = self.getOUG_FormatStart()
        is_magnitude_phase = self.is_magnitude_phase()

        assert self.num_wide == 9, "num_wide=%s not 9" % (self.num_wide)
        nTotal = 36  # 4*9
        format1 += '8f'


        while len(self.data) >= nTotal:
            eData = self.data[0:nTotal]
            self.data = self.data[nTotal:]

            out = unpack(format1, eData)  # num_wide=25
            (eid, fer, uer, aor, aer,
                  fei, uei, aoi, aei) = out
            eid = extract(eid, dt)
            
            if is_magnitude_phase:
                fe = polar_to_real_imag(fer, fei)
                ue = polar_to_real_imag(uer, uei)
                ao = polar_to_real_imag(aor, aoi)
                ae = polar_to_real_imag(aer, aei)
            else:
                fe = complex(fer, fei)
                ue = complex(uer, uei)
                ao = complex(aor, aoi)
                ae = complex(aer, aei)

            self.obj.add_new_eid(self.element_type, dt, eid, fe, ue, ao, ae)
Ejemplo n.º 5
0
    def OES_Rod1_alt(self):
        """
        genericStressReader - works on CROD_1, CELAS2_12
        stress & strain
        format_code=1 sort_code=1 (eid,axial,axial,torsion,torsion)
        """
        dt = self.nonlinear_factor
        (format1, extract) = self.getOUG_FormatStart()
        nTotal = 12
        format1 += '4f'

        is_magnitude_phase = self.is_magnitude_phase()

        n = 0
        nEntries = len(self.data) // nTotal
        for i in range(nEntries):
            eData = self.data[n:n + nTotal]
            (eid, axialReal, axialImag, torsionReal,
                torsionImag) = unpack(format1, eData)

            if is_magnitude_phase:
                (axial) = polar_to_real_imag(axialReal, axialImag)
                (torsion) = polar_to_real_imag(torsionReal, torsionImag)
            else:
                axial = complex(axialReal, axialImag)
                torsion = complex(torsionReal, torsionImag)

            #print "out = ",out
            eid = extract(eid, dt)
            self.obj.add_new_eid(dt, eid, axial, torsion)
            n += nTotal
        self.data = self.data[n:]
Ejemplo n.º 6
0
    def OEF_Spring_alt(self):  # 11-CELAS1, 12-CELAS2, 13-CELAS3, 14-CELAS4
        dt = self.nonlinear_factor
        (format1, extract) = self.getOEF_FormatStart()
        format1 += 'ff'

        is_magnitude_phase = self.is_magnitude_phase()

        while len(self.data) >= 12:  # 3*4
            eData = self.data[0:12]
            self.data = self.data[12:]
            #print "len(data) = ",len(eData)

            out = unpack(format1, eData)
            (eid, forceReal, forceImag) = out
            eid2 = extract(eid, dt)
            #print "eType=%s" %(eType)

            if is_magnitude_phase:
                force = polar_to_real_imag(forceReal, forceImag)
            else:
                force = complex(forceReal, forceImag)

            dataIn = [eid2, force]
            #print "%s" %(self.get_element_type(self.element_type)),dataIn
            #eid = self.obj.add_new_eid(out)
            self.obj.add(dt, dataIn)
Ejemplo n.º 7
0
    def OEF_Beam_alt(self):  # 2-CBEAM
        dt = self.nonlinear_factor
        (format1, extract) = self.getOEF_FormatStart()
        is_magnitude_phase = self.is_magnitude_phase()

        #print self.code_information()
        #nTotal = 16*11+1
        formatAll = 'i15f'


        while len(self.data) >= 708:  # (16*11+1)*4 = 177*4
            eData = self.data[0:4]
            self.data = self.data[4:]
            eidTemp, = unpack(format1, eData)
            eid2 = extract(eidTemp, dt)

            for i in range(11):
                eData = self.data[0:64]
                self.data = self.data[64:]
                #print "len(data) = ",len(eData)

                out = unpack(formatAll, eData)
                (nid, sd, bm1r, bm2r, ts1r, ts2r, afr, ttrqr, wtrqr,
                 bm1i, bm2i, ts1i, ts2i, afi, ttrqi, wtrqi) = out

                if is_magnitude_phase:
                    bm1 = polar_to_real_imag(bm1r, bm1i)
                    bm2 = polar_to_real_imag(bm2r, bm2i)
                    ts1 = polar_to_real_imag(ts1r, ts1i)
                    ts2 = polar_to_real_imag(ts2r, ts2i)
                    af = polar_to_real_imag(afr, afi)
                    ttrq = polar_to_real_imag(ttrqr, ttrqi)
                    wtrq = polar_to_real_imag(wtrqr, wtrqi)
                else:
                    bm1 = complex(bm1r, bm1i)
                    bm2 = complex(bm2r, bm2i)
                    ts1 = complex(ts1r, ts1i)
                    ts2 = complex(ts2r, ts2i)
                    af = complex(afr, afi)
                    ttrq = complex(ttrqr, ttrqi)
                    wtrq = complex(wtrqr, wtrqi)
                #print "eidTemp = ",eidTemp
                #print "nid = ",nid
                #print "sd = ",sd

                #eid = self.obj.add_new_eid(out)
                if i == 0:  # isNewElement:
                    dataIn = [eid2, nid, sd, bm1, bm2,
                              ts1, ts2, af, ttrq, wtrq]
                    #print "%s cNew   " %(self.get_element_type(self.element_type)),dataIn
                    self.obj.addNewElement(dt, dataIn)
                    #print
                elif sd > 0.:
                    dataIn = [eid2, nid, sd, bm1, bm2,
                              ts1, ts2, af, ttrq, wtrq]
                    #print "%s cOld   " %(self.get_element_type(self.element_type)),dataIn
                    self.obj.add(dt, dataIn)
Ejemplo n.º 8
0
    def OES_CBAR_34_alt(self):
        dt = self.nonlinear_factor
        #print "len(data) = ",len(self.data)
        assert self.num_wide == 19, 'invalid num_wide...num_wide=%s' % (
            self.num_wide)

        (format1, extract) = self.getOUG_FormatStart()
        format1 += '18f'

        is_magnitude_phase = self.is_magnitude_phase()

        while len(self.data) >= 76:
            #self.print_block(self.data)
            eData = self.data[0:76]
            self.data = self.data[76:]
            #print "len(data) = ",len(eData)

            (eid, s1ar, s2ar, s3ar, s4ar, axialr,
             s1ai, s2ai, s3ai, s4ai, axiali,
             s1br, s2br, s3br, s4br,
             s1bi, s2bi, s3bi, s4bi) = unpack(format1, eData)

            if is_magnitude_phase:
                s1a = polar_to_real_imag(s1ar, s1ai)
                s1b = polar_to_real_imag(s1br, s1bi)
                s2a = polar_to_real_imag(s2ar, s2ai)
                s2b = polar_to_real_imag(s2br, s2bi)
                s3a = polar_to_real_imag(s3ar, s3ai)
                s3b = polar_to_real_imag(s3br, s3bi)
                s4a = polar_to_real_imag(s4ar, s4ai)
                s4b = polar_to_real_imag(s4br, s4bi)
                axial = polar_to_real_imag(axialr, axiali)

            else:
                s1a = complex(s1ar, s1ai)
                s1b = complex(s1br, s1bi)
                s2a = complex(s2ar, s2ai)
                s2b = complex(s2br, s2bi)
                s3a = complex(s3ar, s3ai)
                s3b = complex(s3br, s3bi)
                s4a = complex(s4ar, s4ai)
                s4b = complex(s4br, s4bi)
                axial = complex(axialr, axiali)

            eid2 = extract(eid, dt)
            self.obj.add_new_eid('CBAR', dt, eid2, s1a, s2a, s3a, s4a, axial,
                               s1b, s2b, s3b, s4b)
Ejemplo n.º 9
0
    def OES_CBAR_34_alt(self):
        dt = self.nonlinear_factor
        #print "len(data) = ",len(self.data)
        assert self.num_wide == 19, 'invalid num_wide...num_wide=%s' % (
            self.num_wide)

        (format1, extract) = self.getOUG_FormatStart()
        format1 += '18f'

        is_magnitude_phase = self.is_magnitude_phase()

        while len(self.data) >= 76:
            #self.print_block(self.data)
            eData = self.data[0:76]
            self.data = self.data[76:]
            #print "len(data) = ",len(eData)

            (eid, s1ar, s2ar, s3ar, s4ar, axialr, s1ai, s2ai, s3ai, s4ai,
             axiali, s1br, s2br, s3br, s4br, s1bi, s2bi, s3bi,
             s4bi) = unpack(format1, eData)

            if is_magnitude_phase:
                s1a = polar_to_real_imag(s1ar, s1ai)
                s1b = polar_to_real_imag(s1br, s1bi)
                s2a = polar_to_real_imag(s2ar, s2ai)
                s2b = polar_to_real_imag(s2br, s2bi)
                s3a = polar_to_real_imag(s3ar, s3ai)
                s3b = polar_to_real_imag(s3br, s3bi)
                s4a = polar_to_real_imag(s4ar, s4ai)
                s4b = polar_to_real_imag(s4br, s4bi)
                axial = polar_to_real_imag(axialr, axiali)

            else:
                s1a = complex(s1ar, s1ai)
                s1b = complex(s1br, s1bi)
                s2a = complex(s2ar, s2ai)
                s2b = complex(s2br, s2bi)
                s3a = complex(s3ar, s3ai)
                s3b = complex(s3br, s3bi)
                s4a = complex(s4ar, s4ai)
                s4b = complex(s4br, s4bi)
                axial = complex(axialr, axiali)

            eid2 = extract(eid, dt)
            self.obj.add_new_eid('CBAR', dt, eid2, s1a, s2a, s3a, s4a, axial,
                                 s1b, s2b, s3b, s4b)
Ejemplo n.º 10
0
def apply_mag_phase(floats: Any, is_magnitude_phase: bool, isave1: List[int],
                    isave2: List[int]) -> Any:
    """converts mag/phase data to real/imag"""
    if is_magnitude_phase:
        mag = floats[:, isave1]
        phase = floats[:, isave2]
        real_imag = polar_to_real_imag(mag, phase)
    else:
        real = floats[:, isave1]
        imag = floats[:, isave2]
        real_imag = real + 1.j * imag
    return real_imag
Ejemplo n.º 11
0
    def readOGF_numWide16(self):
        dt = self.nonlinear_factor
        (format1, extract) = self.getOEF_FormatStart()
        format1 += 'i8s12f'

        is_magnitude_phase = self.is_magnitude_phase()

        while len(self.data) >= 64:
            eData = self.data[0:4 * 16]
            self.data = self.data[4 * 16:]
            out = unpack(format1, eData)
            (eKey, eid, elemName, f1r, f2r, f3r, m1r, m2r, m3r, f1i, f2i, f3i,
             m1i, m2i, m3i) = out
            eKey = extract(eKey, dt)

            if is_magnitude_phase:
                f1 = polar_to_real_imag(f1r, f1i)
                m1 = polar_to_real_imag(m1r, m1i)
                f2 = polar_to_real_imag(f2r, f2i)
                m2 = polar_to_real_imag(m2r, m2i)
                f3 = polar_to_real_imag(f3r, f3i)
                m3 = polar_to_real_imag(m3r, m3i)
            else:
                f1 = complex(f1r, f1i)
                m1 = complex(m1r, m1i)
                f2 = complex(f2r, f2i)
                m2 = complex(m2r, m2i)
                f3 = complex(f3r, f3i)
                m3 = complex(m3r, m3i)

            elemName = elemName.strip()
            #print "eid/dt/freq=%s eid=%-6s eName=%-8s f1=%s f2=%s f3=%s m1=%s m2=%s m3=%s" %(ekey,eid,elemName,f1r+f1i,f2r+f2i,f3r+f3i,m1r+m1i,m2r+m2i,m3r+m3i)
            self.obj.add(dt, eKey, eid, elemName, f1, f2, f3, m1, m2, m3)
Ejemplo n.º 12
0
    def readOGF_numWide16(self):
        dt = self.nonlinear_factor
        (format1, extract) = self.getOEF_FormatStart()
        format1 += 'i8s12f'

        is_magnitude_phase = self.is_magnitude_phase()

        while len(self.data) >= 64:
            eData = self.data[0:4 * 16]
            self.data = self.data[4 * 16:]
            out = unpack(format1, eData)
            (eKey, eid, elemName, f1r, f2r, f3r, m1r, m2r, m3r,
                f1i, f2i, f3i, m1i, m2i, m3i) = out
            eKey = extract(eKey, dt)

            if is_magnitude_phase:
                f1 = polar_to_real_imag(f1r, f1i)
                m1 = polar_to_real_imag(m1r, m1i)
                f2 = polar_to_real_imag(f2r, f2i)
                m2 = polar_to_real_imag(m2r, m2i)
                f3 = polar_to_real_imag(f3r, f3i)
                m3 = polar_to_real_imag(m3r, m3i)
            else:
                f1 = complex(f1r, f1i)
                m1 = complex(m1r, m1i)
                f2 = complex(f2r, f2i)
                m2 = complex(m2r, m2i)
                f3 = complex(f3r, f3i)
                m3 = complex(m3r, m3i)

            elemName = elemName.strip()
            #print "eid/dt/freq=%s eid=%-6s eName=%-8s f1=%s f2=%s f3=%s m1=%s m2=%s m3=%s" %(ekey,eid,elemName,f1r+f1i,f2r+f2i,f3r+f3i,m1r+m1i,m2r+m2i,m3r+m3i)
            self.obj.add(dt, eKey, eid, elemName, f1, f2, f3, m1, m2, m3)
Ejemplo n.º 13
0
    def _read_complex_table(self, data, result_name, flag):
        if self.debug4():
            self.binary_debug.write('  _read_complex_table\n')
        assert flag in ['node', 'elem'], flag
        dt = self.nonlinear_factor

        format1 = '2i12f'
        is_magnitude_phase = self.is_magnitude_phase()

        n = 0
        ntotal = 56  # 14 * 4

        obj = self.obj
        nnodes = len(data) // ntotal
        s = Struct(format1)

        assert self.obj is not None
        assert nnodes > 0
        #assert len(data) % ntotal == 0

        if self.debug4():
            self.binary_debug.write('  nnodes=%i\n' % (nnodes))
        for inode in range(nnodes):
            edata = data[n:n+ntotal]
            out = s.unpack(edata)

            (eid_device, grid_type, txr, tyr, tzr, rxr, ryr, rzr,
             txi, tyi, tzi, rxi, ryi, rzi) = out
            eid = (eid_device - self.device_code) // 10

            if self.debug4():
                self.binary_debug.write('  %s=%i %s\n' % (flag, eid, str(out)))
            if is_magnitude_phase:
                tx = polar_to_real_imag(txr, txi)
                ty = polar_to_real_imag(tyr, tyi)
                tz = polar_to_real_imag(tzr, tzi)

                rx = polar_to_real_imag(rxr, rxi)
                ry = polar_to_real_imag(ryr, ryi)
                rz = polar_to_real_imag(rzr, rzi)
            else:
                tx = complex(txr, txi)
                ty = complex(tyr, tyi)
                tz = complex(tzr, tzi)

                rx = complex(rxr, rxi)
                ry = complex(ryr, ryi)
                rz = complex(rzr, rzi)

            obj.add(dt, eid, grid_type, tx, ty, tz, rx, ry, rz)
            n += ntotal
        return n
Ejemplo n.º 14
0
    def OEF_CBar_alt(self):  # 34-CBAR
        dt = self.nonlinear_factor
        (format1, extract) = self.getOEF_FormatStart()
        format1 += '16f'

        is_magnitude_phase = self.is_magnitude_phase()

        while len(self.data) >= 68:  # 17*4
            eData = self.data[0:68]
            self.data = self.data[68:]
            #print "len(data) = ",len(eData)

            out = unpack(format1, eData)
            (eid, bm1ar, bm2ar, bm1br, bm2br, ts1r, ts2r, afr, trqr,
             bm1ai, bm2ai, bm1bi, bm2bi, ts1i, ts2i, afi, trqi) = out
            eid2 = extract(eid, dt)
            #print "eType=%s" %(eType)

            if is_magnitude_phase:
                bm1a = polar_to_real_imag(bm1ar, bm1ai)
                bm2a = polar_to_real_imag(bm2ar, bm2ai)
                bm1b = polar_to_real_imag(bm1br, bm1bi)
                bm2b = polar_to_real_imag(bm2br, bm2bi)
                ts1 = polar_to_real_imag(ts1r, ts1i)
                ts2 = polar_to_real_imag(ts2r, ts2i)
                af = polar_to_real_imag(afr, afi)
                trq = polar_to_real_imag(trqr, trqi)
            else:
                bm1a = complex(bm1ar, bm1ai)
                bm2a = complex(bm2ar, bm2ai)
                bm1b = complex(bm1br, bm1bi)
                bm2b = complex(bm2br, bm2bi)
                ts1 = complex(ts1r, ts1i)
                ts2 = complex(ts2r, ts2i)
                af = complex(afr, afi)
                trq = complex(trqr, trqi)

            dataIn = [eid2, bm1a, bm2a, bm1b, bm2b, ts1, ts2, af, trq]
            #print "%s" %(self.get_element_type(self.element_type)),dataIn
            #eid = self.obj.add_new_eid(out)
            self.obj.add(dt, dataIn)
Ejemplo n.º 15
0
    def OEF_Plate_alt(self):  # 33-CQUAD4,74-CTRIA3
        dt = self.nonlinear_factor
        (format1, extract) = self.getOEF_FormatStart()
        format1 += '16f'

        is_magnitude_phase = self.is_magnitude_phase()

        while len(self.data) >= 68:  # 17*4
            eData = self.data[0:68]
            self.data = self.data[68:]
            #print "len(data) = ",len(eData)

            out = unpack(format1, eData)
            (eid, mxr, myr, mxyr, bmxr, bmyr, bmxyr, txr, tyr,
             mxi, myi, mxyi, bmxi, bmyi, bmxyi, txi, tyi) = out
            eid2 = extract(eid, dt)
            #print "eType=%s" %(eType)

            if is_magnitude_phase:
                mx = polar_to_real_imag(mxr, mxi)
                my = polar_to_real_imag(myr, myi)
                mxy = polar_to_real_imag(mxyr, mxyi)
                bmx = polar_to_real_imag(bmxr, bmxi)
                bmy = polar_to_real_imag(bmyr, bmyi)
                bmxy = polar_to_real_imag(bmxyr, bmxyi)
                tx = polar_to_real_imag(txr, txi)
                ty = polar_to_real_imag(tyr, tyi)
            else:
                mx = complex(mxr, mxi)
                my = complex(myr, myi)
                mxy = complex(mxyr, mxyi)
                bmx = complex(bmxr, bmxi)
                bmy = complex(bmyr, bmyi)
                bmxy = complex(bmxyr, bmxyi)
                tx = complex(txr, txi)
                ty = complex(tyr, tyi)

            dataIn = [eid2, mx, my, mxy, bmx, bmy, bmxy, tx, ty]
            #print "%s" %(self.get_element_type(self.element_type)),dataIn
            #eid = self.obj.add_new_eid(out)
            self.obj.add(dt, dataIn)
Ejemplo n.º 16
0
    def _read_complex_table2(self, data, result_name, flag):
        #return
        if self.debug4():
            self.binary_debug.write('  _read_complex_table\n')
        assert flag in ['node', 'elem'], flag
        dt = self.nonlinear_factor

        format1 = 'fi12f'
        is_magnitude_phase = self.is_magnitude_phase()

        n = 0
        ntotal = 56  # 14 * 4
        nnodes = len(data) // ntotal
        s = Struct(format1)

        assert self.obj is not None
        assert nnodes > 0
        #assert len(data) % ntotal == 0

        for inode in xrange(nnodes):
            edata = data[n:n + ntotal]
            out = s.unpack(edata)

            (freq, grid_type, txr, tyr, tzr, rxr, ryr, rzr, txi, tyi, tzi, rxi,
             ryi, rzi) = out

            if self.debug4():
                self.binary_debug.write('  %s=%i %s\n' %
                                        ('freq', freq, str(out)))
            if is_magnitude_phase:
                tx = polar_to_real_imag(txr, txi)
                ty = polar_to_real_imag(tyr, tyi)
                tz = polar_to_real_imag(tzr, tzi)

                rx = polar_to_real_imag(rxr, rxi)
                ry = polar_to_real_imag(ryr, ryi)
                rz = polar_to_real_imag(rzr, rzi)
            else:
                tx = complex(txr, txi)
                ty = complex(tyr, tyi)
                tz = complex(tzr, tzi)

                rx = complex(rxr, rxi)
                ry = complex(ryr, ryi)
                rz = complex(rzr, rzi)

            data_in = [freq, grid_type, tx, ty, tz, rx, ry, rz]
            self.obj.add(dt, data_in)
            n += ntotal
        return n
Ejemplo n.º 17
0
    def _read_complex_table2(self, data, result_name, flag):
        #return
        if self.debug4():
            self.binary_debug.write('  _read_complex_table\n')
        assert flag in ['node', 'elem'], flag
        dt = self.nonlinear_factor

        format1 = 'fi12f'
        is_magnitude_phase = self.is_magnitude_phase()

        n = 0
        ntotal = 56  # 14 * 4
        nnodes = len(data) // ntotal
        s = Struct(format1)

        assert self.obj is not None
        assert nnodes > 0
        #assert len(data) % ntotal == 0

        for inode in xrange(nnodes):
            edata = data[n:n+ntotal]
            out = s.unpack(edata)

            (freq, grid_type, txr, tyr, tzr, rxr, ryr, rzr,
             txi, tyi, tzi, rxi, ryi, rzi) = out

            if self.debug4():
                self.binary_debug.write('  %s=%i %s\n' % ('freq', freq, str(out)))
            if is_magnitude_phase:
                tx = polar_to_real_imag(txr, txi)
                ty = polar_to_real_imag(tyr, tyi)
                tz = polar_to_real_imag(tzr, tzi)

                rx = polar_to_real_imag(rxr, rxi)
                ry = polar_to_real_imag(ryr, ryi)
                rz = polar_to_real_imag(rzr, rzi)
            else:
                tx = complex(txr, txi)
                ty = complex(tyr, tyi)
                tz = complex(tzr, tzi)

                rx = complex(rxr, rxi)
                ry = complex(ryr, ryi)
                rz = complex(rzr, rzi)

            data_in = [freq, grid_type, tx, ty, tz, rx, ry, rz]
            self.obj.add(dt, data_in)
            n += ntotal
        return n
Ejemplo n.º 18
0
    def OES_CTRIA3_74_alt(self):  # in progress
        """
        DISTANCE,NORMAL-X,NORMAL-Y,SHEAR-XY,ANGLE,MAJOR,MINOR,VONMISES
        stress is extracted at the centroid
        """
        assert self.num_wide == 15, 'invalid num_wide...num_wide=%s' % (
            self.num_wide)

        dt = self.nonlinear_factor
        (format1, extract) = self.getOUG_FormatStart()
        format1 += '14f'

        is_magnitude_phase = self.is_magnitude_phase()

        while len(self.data) >= 60:
            eData = self.data[0:60]  # 4*15=60
            self.data = self.data[60:]
            out = unpack(format1, eData)

            (eid, fd1, sx1r, sx1i, sy1r, sy1i, txy1r, txy1i,
             fd2, sx2r, sx2i, sy2r, sy2i, txy2r, txy2i) = out

            if is_magnitude_phase:
                sx1 = polar_to_real_imag(sx1r, sx1i)
                sy1 = polar_to_real_imag(sy1r, sy1i)
                sx2 = polar_to_real_imag(sx2r, sx2i)
                sy2 = polar_to_real_imag(sy2r, sy2i)
                txy1 = polar_to_real_imag(txy1r, txy1i)
                txy2 = polar_to_real_imag(txy2r, txy2i)
            else:
                sx1 = complex(sx1r, sx1i)
                sy1 = complex(sy1r, sy1i)
                sx2 = complex(sx2r, sx2i)
                sy2 = complex(sy2r, sy2i)
                txy1 = complex(txy1r, txy1i)
                txy2 = complex(txy2r, txy2i)

            eid = extract(eid, dt)
            #print "eid=%i fd1=%i sx1=%i sy1=%i txy1=%i" %(eid,fd1,sx1,sy1,txy1)
            #print  "      fd2=%i sx2=%i sy2=%i txy2=%i\n"   %(fd2,sx2,sy2,txy2)
            self.obj.add_new_eid('CTRIA3', dt, eid, 'C', fd1, sx1, sy1, txy1)
            self.obj.add(dt, eid, 'C', fd2, sx2, sy2, txy2)
            if self.make_op2_debug:
                self.op2Debug.write('%s\n' % str(out))
Ejemplo n.º 19
0
    def OES_CTRIA3_74_alt(self):  # in progress
        """
        DISTANCE,NORMAL-X,NORMAL-Y,SHEAR-XY,ANGLE,MAJOR,MINOR,VONMISES
        stress is extracted at the centroid
        """
        assert self.num_wide == 15, 'invalid num_wide...num_wide=%s' % (
            self.num_wide)

        dt = self.nonlinear_factor
        (format1, extract) = self.getOUG_FormatStart()
        format1 += '14f'

        is_magnitude_phase = self.is_magnitude_phase()

        while len(self.data) >= 60:
            eData = self.data[0:60]  # 4*15=60
            self.data = self.data[60:]
            out = unpack(format1, eData)

            (eid, fd1, sx1r, sx1i, sy1r, sy1i, txy1r, txy1i, fd2, sx2r, sx2i,
             sy2r, sy2i, txy2r, txy2i) = out

            if is_magnitude_phase:
                sx1 = polar_to_real_imag(sx1r, sx1i)
                sy1 = polar_to_real_imag(sy1r, sy1i)
                sx2 = polar_to_real_imag(sx2r, sx2i)
                sy2 = polar_to_real_imag(sy2r, sy2i)
                txy1 = polar_to_real_imag(txy1r, txy1i)
                txy2 = polar_to_real_imag(txy2r, txy2i)
            else:
                sx1 = complex(sx1r, sx1i)
                sy1 = complex(sy1r, sy1i)
                sx2 = complex(sx2r, sx2i)
                sy2 = complex(sy2r, sy2i)
                txy1 = complex(txy1r, txy1i)
                txy2 = complex(txy2r, txy2i)

            eid = extract(eid, dt)
            #print "eid=%i fd1=%i sx1=%i sy1=%i txy1=%i" %(eid,fd1,sx1,sy1,txy1)
            #print  "      fd2=%i sx2=%i sy2=%i txy2=%i\n"   %(fd2,sx2,sy2,txy2)
            self.obj.add_new_eid('CTRIA3', dt, eid, 'C', fd1, sx1, sy1, txy1)
            self.obj.add(dt, eid, 'C', fd2, sx2, sy2, txy2)
            if self.make_op2_debug:
                self.op2Debug.write('%s\n' % str(out))
Ejemplo n.º 20
0
    def OUG_ComplexTable(self):
        dt = self.nonlinear_factor

        (format1, extract) = self.getOUG_FormatStart()
        
        format1 += 'i12f'
        #print "format1 = ",format1
        is_magnitude_phase = self.is_magnitude_phase()

        while len(self.data) >= 56:  # 14*4
            eData = self.data[0:56]
            self.data = self.data[56:]
            #print "len(data) = ",len(eData)

            out = unpack(format1, eData)
            (eid, gridType, txr, tyr, tzr, rxr, ryr, rzr,
             txi, tyi, tzi, rxi, ryi, rzi) = out

            if is_magnitude_phase:
                tx = polar_to_real_imag(txr, txi)
                rx = polar_to_real_imag(rxr, rxi)
                ty = polar_to_real_imag(tyr, tyi)
                ry = polar_to_real_imag(ryr, ryi)
                tz = polar_to_real_imag(tzr, tzi)
                rz = polar_to_real_imag(rzr, rzi)
            else:
                tx = complex(txr, txi)
                rx = complex(rxr, rxi)
                ty = complex(tyr, tyi)
                ry = complex(ryr, ryi)
                tz = complex(tzr, tzi)
                rz = complex(rzr, rzi)

            eid2 = extract(eid, dt)
            #print "eType=%s" %(eType)

            dataIn = [eid2, gridType, tx, ty, tz, rx, ry, rz]
            #print "%s" %(self.get_element_type(self.element_type)),dataIn
            #eid = self.obj.add_new_eid(out)
            self.obj.add(dt, dataIn)
Ejemplo n.º 21
0
    def OUG_ComplexTable(self):
        dt = self.nonlinear_factor

        (format1, extract) = self.getOUG_FormatStart()

        format1 += 'i12f'
        #print "format1 = ",format1
        is_magnitude_phase = self.is_magnitude_phase()

        while len(self.data) >= 56:  # 14*4
            eData = self.data[0:56]
            self.data = self.data[56:]
            #print "len(data) = ",len(eData)

            out = unpack(format1, eData)
            (eid, gridType, txr, tyr, tzr, rxr, ryr, rzr, txi, tyi, tzi, rxi,
             ryi, rzi) = out

            if is_magnitude_phase:
                tx = polar_to_real_imag(txr, txi)
                rx = polar_to_real_imag(rxr, rxi)
                ty = polar_to_real_imag(tyr, tyi)
                ry = polar_to_real_imag(ryr, ryi)
                tz = polar_to_real_imag(tzr, tzi)
                rz = polar_to_real_imag(rzr, rzi)
            else:
                tx = complex(txr, txi)
                rx = complex(rxr, rxi)
                ty = complex(tyr, tyi)
                ry = complex(ryr, ryi)
                tz = complex(tzr, tzi)
                rz = complex(rzr, rzi)

            eid2 = extract(eid, dt)
            #print "eType=%s" %(eType)

            dataIn = [eid2, gridType, tx, ty, tz, rx, ry, rz]
            #print "%s" %(self.get_element_type(self.element_type)),dataIn
            #eid = self.obj.add_new_eid(out)
            self.obj.add(dt, dataIn)
Ejemplo n.º 22
0
    def OEF_PentaPressure_alt(self):  # 76-CHEXA_PR,77-CPENTA_PR,78-CTETRA_PR
        dt = self.nonlinear_factor
        (format1, extract) = self.getOEF_FormatStart()
        format1 += '8s13f'

        is_magnitude_phase = self.is_magnitude_phase()

        while len(self.data) >= 64:  # 16*4
            eData = self.data[0:64]
            self.data = self.data[64:]
            #print "len(data) = ",len(eData)

            out = unpack(format1, eData)
            (eid, eName, axr, ayr, azr, vxr, vyr, vzr, pressure,
             axi, ayi, azi, vxi, vyi, vzi) = out
            eid2 = extract(eid, dt)
            eName = eName.decode('utf-8').strip()
            #print "eType=%s" %(eType)

            if is_magnitude_phase:
                ax = polar_to_real_imag(axr, axi)
                vx = polar_to_real_imag(vxr, vxi)
                ay = polar_to_real_imag(ayr, ayi)
                vy = polar_to_real_imag(vyr, vyi)
                az = polar_to_real_imag(azr, azi)
                vz = polar_to_real_imag(vzr, vzi)
            else:
                ax = complex(axr, axi)
                vx = complex(vxr, vxi)
                ay = complex(ayr, ayi)
                vy = complex(vyr, vyi)
                az = complex(azr, azi)
                vz = complex(vzr, vzi)

            dataIn = [eid2, eName, ax, ay, az, vx, vy, vz, pressure]
            #print "%s" %(self.get_element_type(self.element_type)),dataIn
            #eid = self.obj.add_new_eid(out)
            self.obj.add(dt, dataIn)
Ejemplo n.º 23
0
    def OEF_CBush_alt(self):  # 102-CBUSH
        dt = self.nonlinear_factor
        (format1, extract) = self.getOEF_FormatStart()
        format1 += '12f'

        is_magnitude_phase = self.is_magnitude_phase()

        while len(self.data) >= 52:  # 13*4
            eData = self.data[0:52]
            self.data = self.data[52:]
            #print "len(data) = ",len(eData)

            out = unpack(format1, eData)
            (eid, fxr, fyr, fzr, mxr, myr, mzr,
             fxi, fyi, fzi, mxi, myi, mzi) = out
            eid2 = extract(eid, dt)
            #print "eType=%s" %(eType)

            if is_magnitude_phase:
                fx = polar_to_real_imag(fxr, fxi)
                mx = polar_to_real_imag(mxr, mxi)
                fy = polar_to_real_imag(fyr, fyi)
                my = polar_to_real_imag(myr, myi)
                fz = polar_to_real_imag(fzr, fzi)
                mz = polar_to_real_imag(mzr, mzi)
            else:
                fx = complex(fxr, fxi)
                mx = complex(mxr, mxi)
                fy = complex(fyr, fyi)
                my = complex(myr, myi)
                fz = complex(fzr, fzi)
                mz = complex(mzr, mzi)

            dataIn = [eid2, fx, fy, fz, mx, my, mz]
            #print "%s" %(self.get_element_type(self.element_type)),dataIn
            #eid = self.obj.add_new_eid(out)
            self.obj.add(dt, dataIn)
Ejemplo n.º 24
0
    def OES_CBUSH_102_alt(self):
        dt = self.nonlinear_factor
        (format1, extract) = self.getOUG_FormatStart()
        is_magnitude_phase = self.is_magnitude_phase()

        assert self.num_wide == 13, "num_wide=%s not 14" % (self.num_wide)
        nTotal = 52  # 4*13
        format1 += '12f'

        while len(self.data) >= nTotal:
            eData = self.data[0:nTotal]
            self.data = self.data[nTotal:]

            out = unpack(format1, eData)  # num_wide=25
            (eid, txr, tyr, tzr, rxr, ryr, rzr, txi, tyi, tzi, rxi, ryi,
             rzi) = out
            eid = extract(eid, dt)

            if is_magnitude_phase:
                tx = polar_to_real_imag(txr, txi)
                ty = polar_to_real_imag(tyr, tyi)
                tz = polar_to_real_imag(tzr, tzi)
                rx = polar_to_real_imag(rxr, rxi)
                ry = polar_to_real_imag(ryr, ryi)
                rz = polar_to_real_imag(rzr, rzi)
            else:
                tx = complex(txr, txi)
                ty = complex(tyr, tyi)
                tz = complex(tzr, tzi)
                rx = complex(rxr, rxi)
                ry = complex(ryr, ryi)
                rz = complex(rzr, rzi)

            #data = (eid, tx, ty, tz, rx, ry, rz)
            self.obj.add_new_eid(self.element_type, dt, eid, tx, ty, tz, rx,
                                 ry, rz)
Ejemplo n.º 25
0
    def OES_CBUSH_102_alt(self):
        dt = self.nonlinear_factor
        (format1, extract) = self.getOUG_FormatStart()
        is_magnitude_phase = self.is_magnitude_phase()

        assert self.num_wide == 13, "num_wide=%s not 14" % (self.num_wide)
        nTotal = 52  # 4*13
        format1 += '12f'


        while len(self.data) >= nTotal:
            eData = self.data[0:nTotal]
            self.data = self.data[nTotal:]

            out = unpack(format1, eData)  # num_wide=25
            (eid, txr,tyr,tzr,rxr,ryr,rzr,
                  txi,tyi,tzi,rxi,ryi,rzi) = out
            eid = extract(eid, dt)
            
            if is_magnitude_phase:
                tx = polar_to_real_imag(txr, txi)
                ty = polar_to_real_imag(tyr, tyi)
                tz = polar_to_real_imag(tzr, tzi)
                rx = polar_to_real_imag(rxr, rxi)
                ry = polar_to_real_imag(ryr, ryi)
                rz = polar_to_real_imag(rzr, rzi)
            else:
                tx = complex(txr, txi)
                ty = complex(tyr, tyi)
                tz = complex(tzr, tzi)
                rx = complex(rxr, rxi)
                ry = complex(ryr, ryi)
                rz = complex(rzr, rzi)

            #data = (eid, tx, ty, tz, rx, ry, rz)
            self.obj.add_new_eid(self.element_type, dt, eid, tx, ty, tz, rx, ry, rz)
Ejemplo n.º 26
0
    def _read_grid_point_forces(self, data, ndata):
        """
        table_code = 19
        """
        dt = self.nonlinear_factor
        n = 0
        is_magnitude_phase = self.is_magnitude_phase()

        if self.thermal == 0:
            result_name = 'grid_point_forces'
            if self._results.is_not_saved(result_name):
                return ndata
            self._results._found_result(result_name)
            slot = getattr(self, result_name)

            if self.num_wide == 10:
                ntotal = 40
                nnodes = ndata // ntotal
                obj_vector_real = RealGridPointForcesArray
                auto_return, is_vectorized = self._create_ntotal_object(
                    nnodes, result_name, slot, obj_vector_real)
                if auto_return:
                    return nnodes * self.num_wide * 4

                obj = self.obj
                if self.is_debug_file:
                    self.binary_debug.write('  GPFORCE\n')
                    self.binary_debug.write('  [cap, gpforce1, gpforce2, ..., cap]\n')
                    self.binary_debug.write('  cap = %i  # assume 1 cap when there could have been multiple\n' % len(data))
                    self.binary_debug.write('  gpforce1 = [nid_device, eid, elem_name, f1, f2, f3, m1, m2, m3]\n')
                    self.binary_debug.write('  nnodes=%i\n' % nnodes)

                if self.use_vector and is_vectorized:
                    # self.itime = 0
                    # self.ielement = 0
                    # self.itotal = 0
                    #self.ntimes = 0
                    #self.nelements = 0
                    n = nnodes * self.num_wide * 4

                    istart = obj.itotal
                    iend = istart + nnodes
                    obj._times[obj.itime] = dt

                    itime = obj.itime
                    if itime == 0 or obj.is_unique:
                        ints = fromstring(data, dtype=self.idtype).reshape(nnodes, 10)

                        nids = ints[:, 0] // 10
                        eids = ints[:, 1]
                        strings = fromstring(data, dtype=self._endian + 'S8').reshape(nnodes, 5)#[:, 2:3]
                        if obj.is_unique:
                            obj.node_element[itime, istart:iend, 0] = nids
                            obj.node_element[itime, istart:iend, 1] = eids
                            obj.element_names[itime, istart:iend] = strings[:, 1]
                        else:
                            obj.node_element[istart:iend, 0] = nids
                            obj.node_element[istart:iend, 1] = eids
                            obj.element_names[istart:iend] = strings[:, 1]


                    floats = fromstring(data, dtype=self.fdtype).reshape(nnodes, 10)
                    #[f1, f2, f3, m1, m2, m3]
                    obj.data[itime, istart:iend, :] = floats[:, 4:]
                    #obj._times[obj.itime] = dt
                    #obj.itotal = itotal2
                    if self.is_debug_file:
                        if itime != 0:
                            ints = fromstring(data, dtype=self.idtype).reshape(nnodes, 10)
                            strings = fromstring(data, dtype=self._endian + 'S8').reshape(nnodes, 5)
                        for i in range(iend - istart):
                            self.binary_debug.write('  nid=%s - (%s, %s, %s, %s, %s, %s, %s, %s, %s)\n' % (
                                ints[i, 0] // 10,
                                ints[i, 0], ints[i, 1], strings[i, 1],
                                floats[i, 4], floats[i, 5], floats[i, 6],
                                floats[i, 7], floats[i, 8], floats[i, 9], ))
                else:
                    s = Struct(b(self._endian + 'ii8s6f'))
                    for i in range(nnodes):
                        edata = data[n:n+ntotal]
                        out = s.unpack(edata)
                        (nid_device, eid, elem_name, f1, f2, f3, m1, m2, m3) = out
                        nid = nid_device // 10
                        elem_name = elem_name.strip()
                        if self.is_debug_file:
                            self.binary_debug.write('  nid=%s - %s\n' % (nid, str(out)))
                        self.obj.add(dt, nid, eid, elem_name, f1, f2, f3, m1, m2, m3)
                        n += ntotal
            elif self.num_wide == 16:
                # complex
                ntotal = 64
                nnodes = ndata // ntotal
                obj_vector_real = ComplexGridPointForcesArray
                auto_return, is_vectorized = self._create_ntotal_object(
                    nnodes, result_name, slot, obj_vector_real)
                if auto_return:
                    return nnodes * self.num_wide * 4

                obj = self.obj
                is_vectorized = False
                if self.use_vector and is_vectorized:
                    # self.itime = 0
                    # self.ielement = 0
                    # self.itotal = 0
                    #self.ntimes = 0
                    #self.nelements = 0
                    n = nnodes * self.num_wide * 4

                    istart = obj.itotal
                    iend = istart + nnodes
                    obj._times[obj.itime] = dt

                    if obj.itime == 0:
                        ints = fromstring(data, dtype=self.idtype).reshape(nnodes, 16)
                        nids = ints[:, 0] // 10
                        eids = ints[:, 1]
                        obj.node_element[istart:iend, 0] = nids
                        obj.node_element[istart:iend, 1] = eids
                        strings = fromstring(data, dtype=self._endian + 'S8').reshape(nnodes, 8)
                        obj.element_names[istart:iend] = strings[:, 1]

                    floats = fromstring(data, dtype=self.fdtype).reshape(nnodes, 16)
                    #[f1, f2, f3, m1, m2, m3]
                    obj.data[obj.itime, istart:iend, :] = floats[:, 4:]
                else:
                    s = Struct(b(self._endian + 'ii8s12f'))

                    #if self.is_debug_file:
                        #self.binary_debug.write('  GPFORCE\n')
                        #self.binary_debug.write('  [cap, gpforce1, gpforce2, ..., cap]\n')
                        #self.binary_debug.write('  cap = %i  # assume 1 cap when there could have been multiple\n' % len(data))
                        #self.binary_debug.write('  gpforce1 = [nid_device, eid, elem_name, f1, f2, f3, m1, m2, m3]\n')
                        #self.binary_debug.write('  nnodes=%i\n' % nnodes)

                    for i in range(nnodes):
                        edata = data[n:n+ntotal]
                        out = s.unpack(edata)
                        (nid_device, eid, elem_name,
                         f1r, f2r, f3r, m1r, m2r, m3r,
                         f1i, f2i, f3i, m1i, m2i, m3i) = out
                        nid = nid_device // 10
                        elem_name = elem_name.strip()
                        if self.is_debug_file:
                            self.binary_debug.write('  nid=%s - %s\n' % (nid, str(out)))

                        if is_magnitude_phase:
                            f1 = polar_to_real_imag(f1r, f1i)
                            f2 = polar_to_real_imag(f2r, f2i)
                            f3 = polar_to_real_imag(f3r, f3i)
                            m1 = polar_to_real_imag(m1r, m1i)
                            m2 = polar_to_real_imag(m2r, m2i)
                            m3 = polar_to_real_imag(m3r, m3i)
                        else:
                            f1 = complex(f1r, f1i)
                            f2 = complex(f2r, f2i)
                            f3 = complex(f3r, f3i)
                            m1 = complex(m1r, m1i)
                            m2 = complex(m2r, m2i)
                            m3 = complex(m3r, m3i)

                        self.obj.add_sort1(dt, nid, eid, elem_name, f1, f2, f3, m1, m2, m3)
                        n += ntotal
            else:
                raise NotImplementedError(self.code_information())
                #msg = self.code_information()
                #return self._not_implemented_or_skip(data, ndata, msg)

            #complex_obj = complexGridPointForcesObject

            #self._read_table(data, storage_obj, real_obj, complex_obj, 'node')
        #elif self.thermal == 1:
            #result_name = 'thermal_load_vectors'
            #storage_obj = self.thermal_load_vectors
            #real_obj = ThermalLoadVectorObject
            #complex_obj = None
            #self._read_table(data, storage_obj, real_obj, complex_obj, 'node')
        else:
            raise NotImplementedError(self.code_information())
            #msg = self.code_information()
            #return self._not_implemented_or_skip(data, ndata, msg)
        return n
Ejemplo n.º 27
0
    def OEF_Plate2_alt(self):  # 64-CQUAD8,70-CTRIAR,75-CTRIA6,82-CQUAD8,144-CQUAD4-bilinear
        dt = self.nonlinear_factor
        (format1, extract) = self.getOEF_FormatStart()
        format1 += '4s'
        is_magnitude_phase = self.is_magnitude_phase()

        if self.element_type in [70, 75]:  # CTRIAR,CTRIA6
            nNodes = 4
        elif self.element_type in [64, 82, 144]:  # CQUAD8,CQUADR,CQUAD4-bilinear
            nNodes = 5
        else:
            raise NotImplementedError(self.code_information())

        allFormat = '17f'


        nTotal = 8 + nNodes * 68
        while len(self.data) >= nTotal:
            eData = self.data[0:76]
            self.data = self.data[76:]
            #print self.print_block(eData)
            #print "len(data) = ",len(eData)

            out = unpack(format1 + allFormat, eData)
            (eid, term, nid, mxr, myr, mxyr, bmxr, bmyr, bmxyr, txr, tyr,
             mxi, myi, mxyi, bmxi, bmyi, bmxyi, txi, tyi) = out
            #term = 'CEN\'
            #print "eType=%s" %(eType)

            eid2 = extract(eid, dt)

            if is_magnitude_phase:
                mx = polar_to_real_imag(mxr, mxi)
                my = polar_to_real_imag(myr, myi)
                mxy = polar_to_real_imag(mxyr, mxyi)
                bmx = polar_to_real_imag(bmxr, bmxi)
                bmy = polar_to_real_imag(bmyr, bmyi)
                bmxy = polar_to_real_imag(bmxyr, bmxyi)
                tx = polar_to_real_imag(txr, txi)
                ty = polar_to_real_imag(tyr, tyi)
            else:
                mx = complex(mxr, mxi)
                my = complex(myr, myi)
                mxy = complex(mxyr, mxyi)
                bmx = complex(bmxr, bmxi)
                bmy = complex(bmyr, bmyi)
                bmxy = complex(bmxyr, bmxyi)
                tx = complex(txr, txi)
                ty = complex(tyr, tyi)

            dataIn = [term, nid, mx, my, mxy, bmx, bmy, bmxy, tx, ty]
            #print "%s" %(self.get_element_type(self.element_type)),dataIn
            self.obj.addNewElement(eid2, dt, dataIn)

            for i in range(nNodes - 1):  # .. todo:: fix crash...
                eData = self.data[0:68]
                self.data = self.data[68:]
                out = unpack(allFormat, eData)

                (nid, mxr, myr, mxyr, bmxr, bmyr, bmxyr, txr, tyr,
                 mxi, myi, mxyi, bmxi, bmyi, bmxyi, txi, tyi) = out
                if is_magnitude_phase:
                    mx = polar_to_real_imag(mxr, mxi)
                    my = polar_to_real_imag(myr, myi)
                    mxy = polar_to_real_imag(mxyr, mxyi)
                    bmx = polar_to_real_imag(bmxr, bmxi)
                    bmy = polar_to_real_imag(bmyr, bmyi)
                    bmxy = polar_to_real_imag(bmxyr, bmxyi)
                    tx = polar_to_real_imag(txr, txi)
                    ty = polar_to_real_imag(tyr, tyi)
                else:
                    mx = complex(mxr, mxi)
                    my = complex(myr, myi)
                    mxy = complex(mxyr, mxyi)
                    bmx = complex(bmxr, bmxi)
                    bmy = complex(bmyr, bmyi)
                    bmxy = complex(bmxyr, bmxyi)
                    tx = complex(txr, txi)
                    ty = complex(tyr, tyi)
                dataIn = [nid, mx, my, mxy, bmx, bmy, bmxy, tx, ty]
                #print "***%s    " %(self.get_element_type(self.element_type)),dataIn

                self.obj.add(eid2, dt, dataIn)
Ejemplo n.º 28
0
    def OEF_Bend_alt(self):  # 69-CBEND
        dt = self.nonlinear_factor
        (format1, extract) = self.getOEF_FormatStart()
        format1 += 'i25f'

        is_magnitude_phase = self.is_magnitude_phase()

        while len(self.data) >= 108:  # 27*4
            eData = self.data[0:108]
            self.data = self.data[108:]
            #print "len(data) = ",len(eData)

            out = unpack(format1, eData)
            (eid, nidA, bm1Ar, bm2Ar, ts1Ar, ts2Ar, afAr, trqAr,
             bm1Ai, bm2Ai, ts1Ai, ts2Ai, afAi, trqAi,
             nidB, bm1Br, bm2Br, ts1Br, ts2Br, afBr, trqBr,
             bm1Bi, bm2Bi, ts1Bi, ts2Bi, afBi, trqBi) = out
            eid2 = extract(eid, dt)
            #print "eType=%s" %(eType)

            if is_magnitude_phase:
                bm1A = polar_to_real_imag(bm1Ar, bm1Ai)
                bm1B = polar_to_real_imag(
                    bm1Br, bm1Bi)
                bm2A = polar_to_real_imag(bm2Ar, bm2Ai)
                bm2B = polar_to_real_imag(
                    bm2Br, bm2Bi)
                ts1A = polar_to_real_imag(ts1Ar, ts1Ai)
                ts1B = polar_to_real_imag(
                    ts1Br, ts1Bi)
                ts2A = polar_to_real_imag(ts2Ar, ts2Ai)
                ts2B = polar_to_real_imag(
                    ts2Br, ts2Bi)
                afA = polar_to_real_imag(afAr,
                                      afAi)
                afB = polar_to_real_imag(afBr, afBi)
                trqA = polar_to_real_imag(trqAr, trqAi)
                trqB = polar_to_real_imag(
                    trqBr, trqBi)
            else:
                bm1A = complex(bm1Ar, bm1Ai)
                bm1B = complex(bm1Br, bm1Bi)
                bm2A = complex(bm2Ar, bm2Ai)
                bm2B = complex(bm2Br, bm2Bi)
                ts1A = complex(ts1Ar, ts1Ai)
                ts1B = complex(ts1Br, ts1Bi)
                ts2A = complex(ts2Ar, ts2Ai)
                ts2B = complex(ts2Br, ts2Bi)
                afA = complex(afAr, afAi)
                afB = complex(afBr, afBi)
                trqA = complex(trqAr, trqAi)
                trqB = complex(trqBr, trqBi)

            dataIn = [eid2, nidA, bm1A, bm2A, ts1A, ts2A, afA, trqA,
                      nidB, bm1B, bm2B, ts1B, ts2B, afB, trqB]
            #print "%s" %(self.get_element_type(self.element_type)),dataIn
            #eid = self.obj.add_new_eid(out)
            self.obj.add(dt, dataIn)
Ejemplo n.º 29
0
    def OEF_Force_VU_alt(self):  # 191-VUBEAM
        dt = self.nonlinear_factor
        (format1, extract) = self.getOEF_FormatStart()
        format1 += '2i4s'

        is_magnitude_phase = self.is_magnitude_phase()

        if self.element_type in [191]:
            nNodes = 2
        else:
            raise NotImplementedError(self.code_information())

        formatAll = 'i13f'

        n = 16 + 56 * nNodes
        while len(self.data) >= n:
            eData = self.data[0:16]  # 8*4
            self.data = self.data[16:]
            #print "len(data) = ",len(eData)

            out = unpack(format1, eData)
            (eid, parent, coord, icord) = out

            eid2 = extract(eid, dt)
            dataIn = [eid2, parent, coord, icord]

            forces = []
            for i in range(nNodes):
                eData = self.data[0:56]  # 14*4
                self.data = self.data[56:]
                #print "i=%s len(data)=%s" %(i,len(eData))
                out = unpack(formatAll, eData)
                [vugrid, posit, forceXr, shearYr, shearZr, torsionr, bendingYr, bendingZr,
                 forceXi, shearYi, shearZi, torsioni, bendingYi, bendingZi] = out

                if is_magnitude_phase:
                    forceX = polar_to_real_imag(forceXr, forceXi)
                    shearY = polar_to_real_imag(shearYr, shearYi)
                    shearZ = polar_to_real_imag(shearZr, shearZi)
                    torsion = polar_to_real_imag(torsionr, torsioni)
                    bendingY = polar_to_real_imag(bendingYr, bendingYi)
                    bendingZ = polar_to_real_imag(bendingZr, bendingZi)
                else:
                    forceX = complex(forceXr, forceXi)
                    shearY = complex(shearYr, shearYi)
                    shearZ = complex(shearZr, shearZi)
                    torsion = complex(torsionr, torsioni)
                    bendingY = complex(bendingYr, bendingYi)
                    bendingZ = complex(bendingZr, bendingZi)

                out2 = [vugrid, posit, forceX, shearY,
                        shearZ, torsion, bendingY, bendingZ]
                forces.append(out2)
            dataIn.append(forces)
            #eType = a+b+c+d+e+f+g+h
            #print "eType=%s" %(eType)

            #dataIn = [vugrid,posit,forceX,shearY,shearZ,torsion,bendY,bendZ]
            #print "force %s" %(self.get_element_type(self.element_type)),dataIn
            #eid = self.obj.add_new_eid(out)
            self.obj.add(nNodes, dt, dataIn)
Ejemplo n.º 30
0
    def OEF_Force_VUTRIA_alt(self):  # 189-VUQUAD,190-VUTRIA
        dt = self.nonlinear_factor
        (format1, extract) = self.getOEF_FormatStart()
        format1 += 'ii4sii'

        is_magnitude_phase = self.is_magnitude_phase()

        if self.element_type in [189]:  # VUQUAD
            nNodes = 4
        elif self.element_type in [190]:  # VUTRIA
            nNodes = 3
        else:
            raise NotImplementedError(self.code_information())

        formatAll = 'i3f3i5fi3f3i5fi'


        n = 24 + 100 * nNodes
        while len(self.data) >= n:
            eData = self.data[0:24]  # 6*4
            self.data = self.data[24:]
            #print "len(data) = ",len(eData)

            out = unpack(format1, eData)
            (eid, parent, coord, icord, theta, _) = out

            eid2 = extract(eid, dt)
            dataIn = [eid2, parent, coord, icord, theta]

            forces = []
            for i in range(nNodes):
                eData = self.data[0:100]  # 13*4
                self.data = self.data[100:]
                #print "i=%s len(data)=%s" %(i,len(eData))
                out = unpack(formatAll, eData)
                [vugrid, mfxr, mfyr, mfxyr, a, b, c, bmxr, bmyr, bmxyr, syzr, szxr, d,
                 mfxi, mfyi, mfxyi, a, b, c, bmxi, bmyi, bmxyi, syzi, szxi, d] = out

                if is_magnitude_phase:
                    mfx = polar_to_real_imag(mfxr, mfxi)
                    mfy = polar_to_real_imag(mfyr, mfyi)
                    mfxy = polar_to_real_imag(mfxyr, mfxyi)
                    bmx = polar_to_real_imag(bmxr, bmxi)
                    bmy = polar_to_real_imag(bmyr, bmyi)
                    bmxy = polar_to_real_imag(bmxyr, bmxyi)
                    syz = polar_to_real_imag(syzr, syzi)
                    szx = polar_to_real_imag(szxr, szxi)
                else:
                    mfx = complex(mfxr, mfxi)
                    mfy = complex(mfyr, mfyi)
                    mfxy = complex(mfxyr, mfxyi)
                    bmx = complex(bmxr, bmxi)
                    bmy = complex(bmyr, bmyi)
                    bmxy = complex(bmxyr, bmxyi)
                    syz = complex(syzr, syzi)
                    szx = complex(szxr, szxi)

                out2 = [vugrid, mfx, mfy, mfxy, bmx, bmy, bmxy, syz, szx]
                forces.append(out2)

            dataIn.append(forces)
            #print "eType=%s" %(eType)

            #dataIn = [vugrid,mfxr,mfyr,mfxyr,bmxr,bmyr,bmxyr,syzr,szxr,
                             #mfxi,mfyi,mfxyi,bmxi,bmyi,bmxyi,syzi,szxi]
            #print "force %s" %(self.get_element_type(self.element_type)),dataIn
            #eid = self.obj.add_new_eid(out)
            self.obj.add(nNodes, dt, dataIn)
Ejemplo n.º 31
0
    def OES_CQUAD4_144_alt(self):
        """
        GRID-ID  DISTANCE,NORMAL-X,NORMAL-Y,SHEAR-XY,ANGLE,MAJOR MINOR,VONMISES
        """
        if self.make_op2_debug:
            self.op2Debug.write('---CQUAD4_144---\n')

        #self.print_section(20)
        #term = data[0:4] CEN/
        #data = data[4:]
        #print "*****"
        #self.print_block(self.data)
        #assert self.num_wide==87,'invalid num_wide...num_wide=%s' %(self.num_wide)
        #if self.num_wide==87: # 2+(17-1)*5 = 87 -> 87*4 = 348

        if self.element_type == 144:  # CQUAD4
            nTotal = 308  # 2+15*5 = 77 -> 87*4 = 308
            nNodes = 4  # centroid + 4 corner points
            eType = 'CQUAD4'
        elif self.element_type == 64:  # CQUAD8 - done
            nTotal = 308  # 2+15*5 = 77 -> 77*4 = 308
            nNodes = 4  # centroid + 4 corner points
            eType = 'CQUAD8'
        elif self.element_type == 82:  # CQUADR
            nTotal = 308  # 2+15*5 = 77 -> 87*4 = 308
            nNodes = 4  # centroid + 4 corner points
            eType = 'CQUAD4'  # TODO write the word CQUADR

        elif self.element_type == 75:  # CTRIA6
            nTotal = 248  # 2+15*3 = 62 -> 62*4 = 248
            nNodes = 3  # centroid + 3 corner points
            eType = 'CTRIA6'
        elif self.element_type == 70:  # CTRIAR
            nTotal = 248  # 2+15*4 = 62 -> 62*4 = 248
            nNodes = 3  # centroid + 3 corner points
            eType = 'CTRIAR'  # TODO write the word CTRIAR
        else:
            raise RuntimeError('element_type=%s nTotal not defined...' %
                               (self.element_type))

        assert nTotal == self.num_wide * 4, 'eType=%s num_wide*4=%s not nTotal=%s' % (
            self.element_type, self.num_wide * 4, nTotal)
        dt = self.nonlinear_factor
        (format1, extract) = self.getOUG_FormatStart()
        format1 += '14f'

        is_magnitude_phase = self.is_magnitude_phase()

        while len(self.data) >= nTotal:
            (eid, _) = unpack('i4s', self.data[0:8])
            self.data = self.data[8:]  # 2
            eid = extract(eid, dt)
            eData = self.data[0:60]  # 4*15
            self.data = self.data[60:]
            out = unpack(format1, eData)  # len=15*4
            if self.make_op2_debug:
                self.op2Debug.write('%s\n' % (str(out)))
            (grid, fd1, sx1r, sx1i, sy1r, sy1i, txy1r, txy1i, fd2, sx2r, sx2i,
             sy2r, sy2i, txy2r, txy2i) = out
            grid = 'C'

            if is_magnitude_phase:
                sx1 = polar_to_real_imag(sx1r, sx1i)
                sy1 = polar_to_real_imag(sy1r, sy1i)
                sx2 = polar_to_real_imag(sx2r, sx2i)
                sy2 = polar_to_real_imag(sy2r, sy2i)
                txy1 = polar_to_real_imag(txy1r, txy1i)
                txy2 = polar_to_real_imag(txy2r, txy2i)
            else:
                sx1 = complex(sx1r, sx1i)
                sy1 = complex(sy1r, sy1i)
                sx2 = complex(sx2r, sx2i)
                sy2 = complex(sy2r, sy2i)
                txy1 = complex(txy1r, txy1i)
                txy2 = complex(txy2r, txy2i)

            self.obj.add_new_eid(eType, dt, eid, grid, fd1, sx1, sy1, txy1)
            self.obj.add(dt, eid, grid, fd2, sx2, sy2, txy2)

            for nodeID in range(nNodes):  # nodes pts
                eData = self.data[0:60]  # 4*15=60
                self.data = self.data[60:]
                out = unpack('i14f', eData)
                if self.make_op2_debug:
                    self.op2Debug.write('%s\n' % (str(out)))
                (grid, fd1, sx1r, sx1i, sy1r, sy1i, txy1r, txy1i, fd2, sx2r,
                 sx2i, sy2r, sy2i, txy2r, txy2i) = out

                if is_magnitude_phase:
                    sx1 = polar_to_real_imag(sx1r, sx1i)
                    sx2 = polar_to_real_imag(sx2r, sx2i)
                    sy1 = polar_to_real_imag(sy1r, sy1i)
                    sy2 = polar_to_real_imag(sy2r, sy2i)
                    txy1 = polar_to_real_imag(txy1r, txy1i)
                    txy2 = polar_to_real_imag(txy2r, txy2i)
                else:
                    sx1 = complex(sx1r, sx1i)
                    sx2 = complex(sx2r, sx2i)
                    sy1 = complex(sy1r, sy1i)
                    sy2 = complex(sy2r, sy2i)
                    txy1 = complex(txy1r, txy1i)
                    txy2 = complex(txy2r, txy2i)

                #print "eid=%i grid=%i fd1=%i sx1=%i sy1=%i txy1=%i"   %(eid,grid,fd1,sx1,sy1,txy1)
                #print "               fd2=%i sx2=%i sy2=%i txy2=%i\n"          %(fd2,sx2,sy2,txy2)
                #print "len(data) = ",len(self.data)
                #self.print_block(self.data)
                self.obj.addNewNode(dt, eid, grid, fd1, sx1, sy1, txy1)
                self.obj.add(dt, eid, grid, fd2, sx2, sy2, txy2)
Ejemplo n.º 32
0
    def OES_CQUAD4_33_alt(self):
        """
        GRID-ID  DISTANCE,NORMAL-X,NORMAL-Y,SHEAR-XY
        """
        dt = self.nonlinear_factor
        (format1, extract) = self.getOUG_FormatStart()
        format1 += '14f'

        is_magnitude_phase = self.is_magnitude_phase()

        nNodes = 0  # centroid + 4 corner points
        #self.print_section(20)
        #term = data[0:4] CEN/
        #data = data[4:]
        #print "*****"
        #self.print_block(self.data)
        #print "self.num_wide = ",self.num_wide
        #print "len(data) = ",len(self.data)

        assert self.num_wide == 15, 'invalid num_wide...num_wide=%s' % (
            self.num_wide)
        while len(self.data) >= 60:  # 2+15*5 = 77 -> 77*4 = 308
            #print self.print_block(self.data[0:100])
            #(eid,) = unpack(b'i',self.data[0:4])
            #print "abcd=",abcd
            #self.data = self.data[8:]  # 2
            eData = self.data[0:60]  # 4*15=60
            self.data = self.data[60:]
            out = unpack(format1, eData)  # 15
            if self.make_op2_debug:
                self.op2Debug.write('%s\n' % (str(out)))
            (eid, fd1, sx1r, sx1i, sy1r, sy1i, txy1r, txy1i,
             fd2, sx2r, sx2i, sy2r, sy2i, txy2r, txy2i) = out

            if is_magnitude_phase:
                sx1 = polar_to_real_imag(sx1r, sx1i)
                sx2 = polar_to_real_imag(sx2r, sx2i)
                sy1 = polar_to_real_imag(sy1r, sy1i)
                sy2 = polar_to_real_imag(sy2r, sy2i)
                txy1 = polar_to_real_imag(txy1r, txy1i)
                txy2 = polar_to_real_imag(txy2r, txy2i)
            else:
                sx1 = complex(sx1r, sx1i)
                sx2 = complex(sx2r, sx2i)
                sy1 = complex(sy1r, sy1i)
                sy2 = complex(sy2r, sy2i)
                txy1 = complex(txy1r, txy1i)
                txy2 = complex(txy2r, txy2i)

            eid = extract(eid, dt)

            #print "eid=%i grid=%s fd1=%-3.1f sx1=%s sy1=%s txy1=%s" %(eid,'C',fd1,sx1,sy1,txy1)
            #print   "             fd2=%-3.1f sx2=%s sy2=%s txy2=%s\n"       %(fd2,sx2,sy2,txy2)
            #print "nNodes = ",nNodes
            self.obj.add_new_eid('CQUAD4', dt, eid, 'C', fd1, sx1, sy1, txy1)
            self.obj.add(dt, eid, 'C', fd2, sx2, sy2, txy2)

            for nodeID in range(nNodes):  # nodes pts
                eData = self.data[0:60]  # 4*15=60
                self.data = self.data[60:]
                out = unpack('i14f', eData[0:60])
                if self.make_op2_debug:
                    self.op2Debug.write('%s\n' % (str(out)))
                (grid, fd1, sx1r, sx1i, sy1r, sy1i, txy1r, txy1i,
                 fd2, sx2r, sx2i, sy2r, sy2i, txy2r, txy2i) = out

                if is_magnitude_phase:
                    sx1 = polar_to_real_imag(sx1r, sx1i)
                    sx2 = polar_to_real_imag(sx2r, sx2i)
                    sy1 = polar_to_real_imag(sy1r, sy1i)
                    sy2 = polar_to_real_imag(sy2r, sy2i)
                    txy1 = polar_to_real_imag(txy1r, txy1i)
                    txy2 = polar_to_real_imag(txy2r, txy2i)
                else:
                    sx1 = complex(sx1r, sx1i)
                    sx2 = complex(sx2r, sx2i)
                    sy1 = complex(sy1r, sy1i)
                    sy2 = complex(sy2r, sy2i)
                    txy1 = complex(txy1r, txy1i)
                    txy2 = complex(txy2r, txy2i)

                #print "eid=%i grid=%i fd1=%i sx1=%i sy1=%i txy1=%i\n" %(eid,grid,fd1,sx1,sy1,txy1)
                #print "               fd2=%i sx2=%i sy2=%i txy2=%i\n"          %(fd2,sx2,sy2,txy2)
                #print "len(data) = ",len(self.data)
                #self.print_block(self.data)
                self.obj.addNewNode(dt, eid, grid, fd1, sx1, sy1, txy1)
                self.obj.add(dt, eid, grid, fd2, sx2, sy2, txy2)
Ejemplo n.º 33
0
    def OES_CQUAD4_33_alt(self):
        """
        GRID-ID  DISTANCE,NORMAL-X,NORMAL-Y,SHEAR-XY
        """
        dt = self.nonlinear_factor
        (format1, extract) = self.getOUG_FormatStart()
        format1 += '14f'

        is_magnitude_phase = self.is_magnitude_phase()

        nNodes = 0  # centroid + 4 corner points
        #self.print_section(20)
        #term = data[0:4] CEN/
        #data = data[4:]
        #print "*****"
        #self.print_block(self.data)
        #print "self.num_wide = ",self.num_wide
        #print "len(data) = ",len(self.data)

        assert self.num_wide == 15, 'invalid num_wide...num_wide=%s' % (
            self.num_wide)
        while len(self.data) >= 60:  # 2+15*5 = 77 -> 77*4 = 308
            #print self.print_block(self.data[0:100])
            #(eid,) = unpack(b'i',self.data[0:4])
            #print "abcd=",abcd
            #self.data = self.data[8:]  # 2
            eData = self.data[0:60]  # 4*15=60
            self.data = self.data[60:]
            out = unpack(format1, eData)  # 15
            if self.make_op2_debug:
                self.op2Debug.write('%s\n' % (str(out)))
            (eid, fd1, sx1r, sx1i, sy1r, sy1i, txy1r, txy1i, fd2, sx2r, sx2i,
             sy2r, sy2i, txy2r, txy2i) = out

            if is_magnitude_phase:
                sx1 = polar_to_real_imag(sx1r, sx1i)
                sx2 = polar_to_real_imag(sx2r, sx2i)
                sy1 = polar_to_real_imag(sy1r, sy1i)
                sy2 = polar_to_real_imag(sy2r, sy2i)
                txy1 = polar_to_real_imag(txy1r, txy1i)
                txy2 = polar_to_real_imag(txy2r, txy2i)
            else:
                sx1 = complex(sx1r, sx1i)
                sx2 = complex(sx2r, sx2i)
                sy1 = complex(sy1r, sy1i)
                sy2 = complex(sy2r, sy2i)
                txy1 = complex(txy1r, txy1i)
                txy2 = complex(txy2r, txy2i)

            eid = extract(eid, dt)

            #print "eid=%i grid=%s fd1=%-3.1f sx1=%s sy1=%s txy1=%s" %(eid,'C',fd1,sx1,sy1,txy1)
            #print   "             fd2=%-3.1f sx2=%s sy2=%s txy2=%s\n"       %(fd2,sx2,sy2,txy2)
            #print "nNodes = ",nNodes
            self.obj.add_new_eid('CQUAD4', dt, eid, 'C', fd1, sx1, sy1, txy1)
            self.obj.add(dt, eid, 'C', fd2, sx2, sy2, txy2)

            for nodeID in range(nNodes):  # nodes pts
                eData = self.data[0:60]  # 4*15=60
                self.data = self.data[60:]
                out = unpack('i14f', eData[0:60])
                if self.make_op2_debug:
                    self.op2Debug.write('%s\n' % (str(out)))
                (grid, fd1, sx1r, sx1i, sy1r, sy1i, txy1r, txy1i, fd2, sx2r,
                 sx2i, sy2r, sy2i, txy2r, txy2i) = out

                if is_magnitude_phase:
                    sx1 = polar_to_real_imag(sx1r, sx1i)
                    sx2 = polar_to_real_imag(sx2r, sx2i)
                    sy1 = polar_to_real_imag(sy1r, sy1i)
                    sy2 = polar_to_real_imag(sy2r, sy2i)
                    txy1 = polar_to_real_imag(txy1r, txy1i)
                    txy2 = polar_to_real_imag(txy2r, txy2i)
                else:
                    sx1 = complex(sx1r, sx1i)
                    sx2 = complex(sx2r, sx2i)
                    sy1 = complex(sy1r, sy1i)
                    sy2 = complex(sy2r, sy2i)
                    txy1 = complex(txy1r, txy1i)
                    txy2 = complex(txy2r, txy2i)

                #print "eid=%i grid=%i fd1=%i sx1=%i sy1=%i txy1=%i\n" %(eid,grid,fd1,sx1,sy1,txy1)
                #print "               fd2=%i sx2=%i sy2=%i txy2=%i\n"          %(fd2,sx2,sy2,txy2)
                #print "len(data) = ",len(self.data)
                #self.print_block(self.data)
                self.obj.addNewNode(dt, eid, grid, fd1, sx1, sy1, txy1)
                self.obj.add(dt, eid, grid, fd2, sx2, sy2, txy2)
Ejemplo n.º 34
0
    def OES_CQUAD4_144_alt(self):
        """
        GRID-ID  DISTANCE,NORMAL-X,NORMAL-Y,SHEAR-XY,ANGLE,MAJOR MINOR,VONMISES
        """
        if self.make_op2_debug:
            self.op2Debug.write('---CQUAD4_144---\n')

        #self.print_section(20)
        #term = data[0:4] CEN/
        #data = data[4:]
        #print "*****"
        #self.print_block(self.data)
        #assert self.num_wide==87,'invalid num_wide...num_wide=%s' %(self.num_wide)
        #if self.num_wide==87: # 2+(17-1)*5 = 87 -> 87*4 = 348

        if self.element_type == 144:  # CQUAD4
            nTotal = 308  # 2+15*5 = 77 -> 87*4 = 308
            nNodes = 4    # centroid + 4 corner points
            eType = 'CQUAD4'
        elif self.element_type == 64:  # CQUAD8 - done
            nTotal = 308  # 2+15*5 = 77 -> 77*4 = 308
            nNodes = 4    # centroid + 4 corner points
            eType = 'CQUAD8'
        elif self.element_type == 82:  # CQUADR
            nTotal = 308  # 2+15*5 = 77 -> 87*4 = 308
            nNodes = 4    # centroid + 4 corner points
            eType = 'CQUAD4'  # TODO write the word CQUADR

        elif self.element_type == 75:  # CTRIA6
            nTotal = 248  # 2+15*3 = 62 -> 62*4 = 248
            nNodes = 3    # centroid + 3 corner points
            eType = 'CTRIA6'
        elif self.element_type == 70:  # CTRIAR
            nTotal = 248  # 2+15*4 = 62 -> 62*4 = 248
            nNodes = 3    # centroid + 3 corner points
            eType = 'CTRIAR'  # TODO write the word CTRIAR
        else:
            raise RuntimeError('element_type=%s nTotal not defined...' %
                            (self.element_type))

        assert nTotal == self.num_wide * 4, 'eType=%s num_wide*4=%s not nTotal=%s' % (self.element_type, self.num_wide * 4, nTotal)
        dt = self.nonlinear_factor
        (format1, extract) = self.getOUG_FormatStart()
        format1 += '14f'

        is_magnitude_phase = self.is_magnitude_phase()

        while len(self.data) >= nTotal:
            (eid, _) = unpack('i4s', self.data[0:8])
            self.data = self.data[8:]  # 2
            eid = extract(eid, dt)
            eData = self.data[0:60]  # 4*15
            self.data = self.data[60:]
            out = unpack(format1, eData)  # len=15*4
            if self.make_op2_debug:
                self.op2Debug.write('%s\n' % (str(out)))
            (grid, fd1, sx1r, sx1i, sy1r, sy1i, txy1r, txy1i,
             fd2, sx2r, sx2i, sy2r, sy2i, txy2r, txy2i) = out
            grid = 'C'

            if is_magnitude_phase:
                sx1 = polar_to_real_imag(sx1r, sx1i)
                sy1 = polar_to_real_imag(
                    sy1r, sy1i)
                sx2 = polar_to_real_imag(sx2r, sx2i)
                sy2 = polar_to_real_imag(
                    sy2r, sy2i)
                txy1 = polar_to_real_imag(txy1r, txy1i)
                txy2 = polar_to_real_imag(
                    txy2r, txy2i)
            else:
                sx1 = complex(sx1r, sx1i)
                sy1 = complex(sy1r, sy1i)
                sx2 = complex(sx2r, sx2i)
                sy2 = complex(sy2r, sy2i)
                txy1 = complex(txy1r, txy1i)
                txy2 = complex(txy2r, txy2i)

            self.obj.add_new_eid(eType, dt, eid, grid, fd1, sx1, sy1, txy1)
            self.obj.add(dt, eid, grid, fd2, sx2, sy2, txy2)

            for nodeID in range(nNodes):  # nodes pts
                eData = self.data[0:60]  # 4*15=60
                self.data = self.data[60:]
                out = unpack('i14f', eData)
                if self.make_op2_debug:
                    self.op2Debug.write('%s\n' % (str(out)))
                (grid, fd1, sx1r, sx1i, sy1r, sy1i, txy1r, txy1i,
                 fd2, sx2r, sx2i, sy2r, sy2i, txy2r, txy2i) = out

                if is_magnitude_phase:
                    sx1 = polar_to_real_imag(sx1r, sx1i)
                    sx2 = polar_to_real_imag(sx2r, sx2i)
                    sy1 = polar_to_real_imag(sy1r, sy1i)
                    sy2 = polar_to_real_imag(sy2r, sy2i)
                    txy1 = polar_to_real_imag(txy1r, txy1i)
                    txy2 = polar_to_real_imag(txy2r, txy2i)
                else:
                    sx1 = complex(sx1r, sx1i)
                    sx2 = complex(sx2r, sx2i)
                    sy1 = complex(sy1r, sy1i)
                    sy2 = complex(sy2r, sy2i)
                    txy1 = complex(txy1r, txy1i)
                    txy2 = complex(txy2r, txy2i)

                #print "eid=%i grid=%i fd1=%i sx1=%i sy1=%i txy1=%i"   %(eid,grid,fd1,sx1,sy1,txy1)
                #print "               fd2=%i sx2=%i sy2=%i txy2=%i\n"          %(fd2,sx2,sy2,txy2)
                #print "len(data) = ",len(self.data)
                #self.print_block(self.data)
                self.obj.addNewNode(dt, eid, grid, fd1, sx1, sy1, txy1)
                self.obj.add(dt, eid, grid, fd2, sx2, sy2, txy2)
Ejemplo n.º 35
0
    def _read_grid_point_forces(self, data, ndata, prefix=''):
        """
        table_code = 19
        """
        self._setup_op2_subcase('GPFORCE')
        dt = self.nonlinear_factor
        n = 0
        is_magnitude_phase = self.is_magnitude_phase()

        if self.thermal == 0:
            result_name = prefix + 'grid_point_forces'
            if self._results.is_not_saved(result_name):
                return ndata
            self._results._found_result(result_name)
            slot = self.get_result(result_name)

            if self.num_wide == 10:
                ntotal = 40
                nnodes = ndata // ntotal
                obj_vector_real = RealGridPointForcesArray
                auto_return, is_vectorized = self._create_ntotal_object(
                    nnodes, result_name, slot, obj_vector_real)
                if auto_return:
                    return nnodes * self.num_wide * 4

                obj = self.obj
                if self.is_debug_file:
                    self.binary_debug.write('  GPFORCE\n')
                    self.binary_debug.write('  [cap, gpforce1, gpforce2, ..., cap]\n')
                    self.binary_debug.write('  cap = %i  # assume 1 cap when there could have been multiple\n' % len(data))
                    self.binary_debug.write('  gpforce1 = [nid_device, eid, elem_name, f1, f2, f3, m1, m2, m3]\n')
                    self.binary_debug.write('  nnodes=%i\n' % nnodes)

                if self.use_vector and is_vectorized:
                    # self.itime = 0
                    # self.ielement = 0
                    # self.itotal = 0
                    #self.ntimes = 0
                    #self.nelements = 0
                    n = nnodes * self.num_wide * 4

                    istart = obj.itotal
                    iend = istart + nnodes
                    obj._times[obj.itime] = dt

                    itime = obj.itime
                    if itime == 0 or obj.is_unique:
                        ints = frombuffer(data, dtype=self.idtype).reshape(nnodes, 10).copy()

                        nids = ints[:, 0] // 10
                        eids = ints[:, 1]
                        strings = frombuffer(data, dtype=self._uendian + 'S8').reshape(nnodes, 5).copy()
                        if obj.is_unique:
                            obj.node_element[itime, istart:iend, 0] = nids
                            obj.node_element[itime, istart:iend, 1] = eids
                            obj.element_names[itime, istart:iend] = strings[:, 1]
                        else:
                            obj.node_element[istart:iend, 0] = nids
                            obj.node_element[istart:iend, 1] = eids
                            obj.element_names[istart:iend] = strings[:, 1]


                    floats = frombuffer(data, dtype=self.fdtype).reshape(nnodes, 10)
                    #[f1, f2, f3, m1, m2, m3]
                    obj.data[itime, istart:iend, :] = floats[:, 4:].copy()
                    #obj._times[obj.itime] = dt
                    #obj.itotal = itotal2
                    if self.is_debug_file:
                        if itime != 0:
                            ints = frombuffer(data, dtype=self.idtype).reshape(nnodes, 10)
                            strings = frombuffer(data, dtype=self._uendian + 'S8').reshape(nnodes, 5)
                        for i in range(iend - istart):
                            self.binary_debug.write('  nid=%s - (%s, %s, %s, %s, %s, %s, %s, %s, %s)\n' % (
                                ints[i, 0] // 10,
                                ints[i, 0], ints[i, 1], strings[i, 1],
                                floats[i, 4], floats[i, 5], floats[i, 6],
                                floats[i, 7], floats[i, 8], floats[i, 9], ))
                else:
                    s = Struct(self._endian + b'ii8s6f')
                    for i in range(nnodes):
                        edata = data[n:n+ntotal]
                        out = s.unpack(edata)
                        (nid_device, eid, elem_name, f1, f2, f3, m1, m2, m3) = out
                        nid = nid_device // 10
                        elem_name = elem_name.strip()
                        if self.is_debug_file:
                            self.binary_debug.write('  nid=%s - %s\n' % (nid, str(out)))
                        self.obj.add_sort1(dt, nid, eid, elem_name, f1, f2, f3, m1, m2, m3)
                        n += ntotal
            elif self.num_wide == 16:
                # complex
                ntotal = 64
                nnodes = ndata // ntotal
                obj_vector_real = ComplexGridPointForcesArray
                auto_return, is_vectorized = self._create_ntotal_object(
                    nnodes, result_name, slot, obj_vector_real)
                if auto_return:
                    return nnodes * self.num_wide * 4

                obj = self.obj
                is_vectorized = False
                if self.use_vector and is_vectorized:
                    # self.itime = 0
                    # self.ielement = 0
                    # self.itotal = 0
                    #self.ntimes = 0
                    #self.nelements = 0
                    n = nnodes * self.num_wide * 4

                    istart = obj.itotal
                    iend = istart + nnodes
                    obj._times[obj.itime] = dt

                    if obj.itime == 0:
                        ints = frombuffer(data, dtype=self.idtype).reshape(nnodes, 16)
                        nids = ints[:, 0] // 10
                        eids = ints[:, 1]
                        obj.node_element[istart:iend, 0] = nids
                        obj.node_element[istart:iend, 1] = eids
                        strings = frombuffer(data, dtype=self._uendian + 'S8').reshape(nnodes, 8)
                        obj.element_names[istart:iend] = strings[:, 1].copy()

                    floats = frombuffer(data, dtype=self.fdtype).reshape(nnodes, 16)
                    #[f1, f2, f3, m1, m2, m3]
                    obj.data[obj.itime, istart:iend, :] = floats[:, 4:].copy()
                else:
                    s = Struct(self._endian + b'ii8s12f')

                    #if self.is_debug_file:
                        #self.binary_debug.write('  GPFORCE\n')
                        #self.binary_debug.write('  [cap, gpforce1, gpforce2, ..., cap]\n')
                        #self.binary_debug.write('  cap = %i  # assume 1 cap when there could have been multiple\n' % len(data))
                        #self.binary_debug.write('  gpforce1 = [nid_device, eid, elem_name, f1, f2, f3, m1, m2, m3]\n')
                        #self.binary_debug.write('  nnodes=%i\n' % nnodes)

                    for i in range(nnodes):
                        edata = data[n:n+ntotal]
                        out = s.unpack(edata)
                        (nid_device, eid, elem_name,
                         f1r, f2r, f3r, m1r, m2r, m3r,
                         f1i, f2i, f3i, m1i, m2i, m3i) = out
                        nid = nid_device // 10
                        elem_name = elem_name.strip()
                        if self.is_debug_file:
                            self.binary_debug.write('  nid=%s - %s\n' % (nid, str(out)))

                        if is_magnitude_phase:
                            f1 = polar_to_real_imag(f1r, f1i)
                            f2 = polar_to_real_imag(f2r, f2i)
                            f3 = polar_to_real_imag(f3r, f3i)
                            m1 = polar_to_real_imag(m1r, m1i)
                            m2 = polar_to_real_imag(m2r, m2i)
                            m3 = polar_to_real_imag(m3r, m3i)
                        else:
                            f1 = complex(f1r, f1i)
                            f2 = complex(f2r, f2i)
                            f3 = complex(f3r, f3i)
                            m1 = complex(m1r, m1i)
                            m2 = complex(m2r, m2i)
                            m3 = complex(m3r, m3i)

                        self.obj.add_sort1(dt, nid, eid, elem_name, f1, f2, f3, m1, m2, m3)
                        n += ntotal
            else:
                raise NotImplementedError(self.code_information())
        else:
            raise NotImplementedError(self.code_information())
            #msg = self.code_information()
            #return self._not_implemented_or_skip(data, ndata, msg)
        return n
Ejemplo n.º 36
0
    def OEF_Shear_alt(self):  # 4-CSHEAR
        dt = self.nonlinear_factor
        (format1, extract) = self.getOEF_FormatStart()
        format1 += '32f'

        is_magnitude_phase = self.is_magnitude_phase()

        while len(self.data) >= 132:  # 33*4
            eData = self.data[0:132]
            self.data = self.data[132:]
            #print "len(data) = ",len(eData)

            out = unpack(format1, eData)
            (eid, f41r, f21r, f12r, f32r, f23r, f43r, f34r, f14r, kf1r, s12r, kf2r, s23r, kf3r, s34r, kf4r, s41r,
                  f41i, f21i, f12i, f32i, f23i, f43i, f34i, f14i, kf1i, s12i, kf2i, s23i, kf3i, s34i, kf4i, s41i) = out
            if is_magnitude_phase:
                f41r = polar_to_real_imag(f41r, f41i)
                kf1 = polar_to_real_imag(kf1r, kf1i)
                f21r = polar_to_real_imag(f21r, f21i)
                kf2 = polar_to_real_imag(kf2r, kf2i)
                f12r = polar_to_real_imag(f12r, f12i)
                kf3 = polar_to_real_imag(kf3r, kf3i)
                f23r = polar_to_real_imag(f23r, f23i)
                kf4 = polar_to_real_imag(kf4r, kf4i)
                f32r = polar_to_real_imag(f32r, f32i)
                s12 = polar_to_real_imag(s12r, s12i)
                f43r = polar_to_real_imag(f43r, f43i)
                s23 = polar_to_real_imag(s23r, s23i)
                f34r = polar_to_real_imag(f34r, f34i)
                s34 = polar_to_real_imag(s34r, s34i)
                f14r = polar_to_real_imag(f14r, f14i)
                s41 = polar_to_real_imag(s41r, s41i)
            else:
                f41 = complex(f41r, f41i)
                kf1 = complex(kf1r, kf1i)
                f21 = complex(f21r, f21i)
                kf2 = complex(kf2r, kf2i)
                f12 = complex(f12r, f12i)
                kf3 = complex(kf3r, kf3i)
                f23 = complex(f23r, f23i)
                kf4 = complex(kf4r, kf4i)
                f32 = complex(f32r, f32i)
                s12 = complex(s12r, s12i)
                f43 = complex(f43r, f43i)
                s23 = complex(s23r, s23i)
                f34 = complex(f34r, f34i)
                s34 = complex(s34r, s34i)
                f14 = complex(f14r, f14i)
                s41 = complex(s41r, s41i)

            eid2 = extract(eid, dt)
            #print "eType=%s" %(eType)

            dataIn = [eid2, f41, f21, f12, f32, f23, f43, f34, f14,
                      kf1, s12, kf2, s23, kf3, s34, kf4, s41]
            #print "%s" %(self.get_element_type(self.element_type)),dataIn
            #eid = self.obj.add_new_eid(out)
            self.obj.add(dt, dataIn)