Beispiel #1
0
    def split_points(self, lines, nfull_lines, npartial_lines):
        """
        reads the points
        """
        ipoint = 0
        nrows = 2 * nfull_lines + npartial_lines
        points = np.zeros((nrows, 3), dtype='float32')

        for n in range(nfull_lines):
            line = lines[n]
            x1 = double(line[0:10], 'x%i' % (ipoint + 1))
            y1 = double(line[10:20], 'y%i' % (ipoint + 1))
            z1 = double(line[20:30], 'z%i' % (ipoint + 1))
            points[ipoint, :] = [x1, y1, z1]
            ipoint += 1

            x2 = double(line[30:40], 'x%i' % (ipoint + 2))
            y2 = double(line[40:50], 'y%i' % (ipoint + 2))
            z2 = double(line[50:60], 'z%i' % (ipoint + 2))
            points[ipoint, :] = [x2, y2, z2]
            ipoint += 1

        if npartial_lines:
            n += 1
            line = lines[n]
            x1 = double(line[0:10], 'x%i' % (ipoint + 1))
            y1 = double(line[10:20], 'y%i' % (ipoint + 1))
            z1 = double(line[20:30], 'z%i' % (ipoint + 1))
            points[ipoint, :] = [x1, y1, z1]

        return points
Beispiel #2
0
    def _read_trailing_wakes(self, section):
        """
        .. code-block:: console

          $trailing wakes from body
          =kn                                               cpnorm
          2.
          =kt       matcw
          18.       1.
          =inat     insd      xwake     twake                                   netname
          bodyl     3.        100.      .0                                      bodylwk
          bodyu     3.        100.      .0                                      bodyuwk
        """
        #return True  # disable wakes
        nnetworks = integer_or_blank(section[1][0:10], 'nnetworks', 0)

        cp_norm = integer_or_blank(section[1][50:60], 'cp_norm', 0)

        #print "section[2] = ",section[2]
        kt = integer(section[2][0:10], 'kt')

        matchw = section[2][10:20].strip()
        if matchw:
            matchw = float(matchw)
        #if cp_norm:
            #print "nnetworks=%s cp_norm=%s" % (nnetworks, cp_norm)
        #else:
            #print "nnetworks=%s" % (nnetworks)
        #print ""
        #matcw = integer(section[2][10:20], 'matcw)

        n = 3  # line number
        self.msg += '      kn,kt            %i          %i\n' % (nnetworks, kt)
        #self.log.debug('kt=%s cp_norm=%s matchw=%s' % (kt, cp_norm, matchw))
        for unused_inetwork in range(nnetworks):
            #self.log.debug("lines[* %s] = %s" % (n, section[n]))

            trailed_panel = section[n][0:10].strip()
            edge_number = integer(section[n][10:20], 'edge_number')
            xwake = double(section[n][20:30], 'xwake')  # x distance

            # 0-wake parallel to x axis
            #1-wake in direction of compressibility
            twake = double(section[n][30:40], 'twake')
            network_name = section[n][70:80].strip()
            self.log.debug('trailed_panel=%s edge_number=%s xwake=%s twake=%s network_name=%s' % (
                trailed_panel, edge_number, xwake, twake, network_name))
            try:
                patch = self.find_patch_by_name(trailed_panel)
            except KeyError:
                self.log.debug('trailed_panel isnt defined...trailed_panel=%r' % (trailed_panel))
                raise

            (unused_p1, xyz1) = patch.get_edge(edge_number)

            npoints = xyz1.shape[0]
            xyz = np.zeros([2, npoints, 3])

            xyz[0, :, :] = xyz1
            if twake == 0.:
                xyz[1, :, 0] = np.ones([npoints]) * xwake
                xyz[1, :, 1] = xyz1[:, 1]
                xyz[1, :, 2] = xyz1[:, 2]
            else:
                #alphaC, betaC
                raise NotImplementedError('twake isnt supported')
            #self.log.debug("--xyz---")
            #self.log.debug(xyz)
            #nm = integer(section[n-1][0 :10], 'nm')
            #nn = integer(section[n-1][10:20], 'nn')
            options = [kt, cp_norm, matchw, trailed_panel, edge_number, xwake,
                       twake]
            patch = self.add_wake_patch(network_name, options, xyz)
            self.log.info('----------------------------')
            n += 1
        return True
Beispiel #3
0
    def _read_printout(self, section):
        """
        .. code-block:: console

          isings  igeomp  isingp  icontp  ibconp  iedgep
          ipraic  nexdgn  ioutpr  ifmcpr  icostp
        """
        #self.printoutSection = '\n'.join(section)+'\n'

        #  ROW 1
        self.isings = double(section[1][0:10], 'isings')
        #self.isings = 5.
        #2.0 output wake singularity grid-singularity strength and gradients at 9 pts/panel
        #3.0 add table of singularity parameter values
        #4.0 add network array of singularity values
        #5.0 add singularity grid for all network

        self.igeomp = double(section[1][10:20], 'igeomp')
        self.igeomp = 1.
        # 1.0 outputs panel data - geometry diagnostic data

        self.isingp = double(section[1][20:30], 'isingp')
        #self.isignp = 1.  # ???
        # 1.0 outputs singularity spline data

        self.icontp = double(section[1][30:40], 1.0)
        self.icontp = 1.0
        # 1.0 outputs control pt location, upper surface unit normals, control point
        #     diagnositc data, control pt maps and singularity parameter maps
        # 2.0 add additional control point map for each network

        self.ibconp = double(section[1][40:50], 'ibconp')
        #self.ibconp = 0.0
        # 1.0 outputs boundary condition coeffs, diagnositc data,
        #     boundary condition maps, control point maps,
        #     and singularity paramter maps

        self.iedgep = double(section[1][50:60], 'iedgep')
        self.iedgep = 0.0
        # 1.0 outputs edge-matching diagnositic data
        #print("igeomp=%r isingp=%r icontp=%r ibconp=%r iedgep=%r" % (
            #igeomp, isingp, icontp, ibconp, iedgep))

        #  ROW 2
        self.ipraic = double(section[2][0:10], 'ipraic')
        #self.ipraic = 3.
        # xxx inputs control point sequence number for
        #     which AIC values are to be pritned (rarely used)

        self.nexdgn = double(section[2][10:20], 'nexdgn')
        self.nexdgn = 0.
        # 1.0 outputs edge and extra control point data

        self.ioutpr = double(section[2][20:30], 'ioutpr')
        self.ioutpr = -1.0
        # -1.0 omits flow parameter output
        #  0.0 outputs 49 flow parameters
        #  1.0 outputs 13 flow parameters

        self.ifmcpr = section[2][30:40].strip()
        self.ifmcpr = 0.
        # 0.0 omits network force and moment output
        # 1.0 outputs network forces and moments summary per column,
        #     per network, and accumulation over all previous networks

        self.icostp = section[2][40:50].strip()
        self.icostp = 0.
        #self.icostp = 1.0
        #print("ipraic=%r nexdgn=%r ioutpr=%r ifmcpr=%r ifmcpr=%r"
              #% (ipraic, nexdgn, ioutpr, ifmcpr, iedgep))
        # 1.0 outputs detailed job cost for different segments of the
        #     program (rarely used)

        #$printout options
        #=isings   igeomp    isingp    icontp    ibconp    iedgep
        #4.        0.        0.        1.        1.        0.
        #=ipraic   nexdgn    ioutpr    ifmcpr
        #.0        .0        1.        0.                  3.
        return True
Beispiel #4
0
    def _read_circular_section(self, section):
        """
        .. code-block:: console
          $circular sections - nacelle with composite panels
          =kn
          2.
          =kt
          1.
          =nopt                                                                 netname
          0.                                                                    cowlu
          =nm
          20.
          =xs(1)    ri(1)     xs(2)     ri(2)     xs(*)     ri(*)
              2.0000    2.3000    1.5756    2.3000    1.1486    2.3000
              0.7460    2.3030    0.4069    2.3286    0.1624    2.3790
              0.0214    2.4542   -0.0200    2.5485    0.0388    2.6522 # 18
              0.2056    2.7554    0.4869    2.8522    0.8883    2.9413
              1.4250    3.0178    2.1188    3.0656    2.9586    3.0658 # 36
              3.8551    3.0175    4.6715    2.9439    5.3492    2.8700 # 42
              6.0000    2.7842    6.4687    2.7442 # 46 ->23
          =nn
          5.
          =th(1)    th(2)     th(3)     th(4)     th(5)
          -90.      -45.      0.        45.       90.
        """
        nnetworks = integer(section[1][0:10], 'nnetworks')
        cp_norm = section[1][50:60].strip()

        kt = integer(section[2][0:10], 'kt')
        if cp_norm:
            self.log.debug("nnetworks=%s cp_norm=%s" % (nnetworks, cp_norm))
        else:
            self.log.debug("nnetworks=%s" % (nnetworks))
        #print("nnetworks=%s cp_norm=%s" % (nnetworks, cp_norm))

        n = 3
        self.msg += '      kn,kt            %i          %i\n' % (nnetworks, kt)

        for unused_inetwork in range(nnetworks):
            #self.log.debug("lines[%s] = %s" % (n, section[n]))
            # 0-noDisplacement; 1-Specify
            ndisplacement = integer(section[n][0:10], 'ndisplacement')
            assert ndisplacement in [0, 1], section[n]
            n += 1

            #print("\nsection[n] = ", section[n].strip())
            nx_nr = integer(section[n][0:10], 'nx_nr')
            assert nx_nr > 0, section[n]
            #print("nxr = %s" % nxr)
            network_name = section[n][70:80]
            #self.log.debug("kt=%s nx_nr=%s ndisplacement=%s network_name=%s" %
                           #(kt, nx_nr, ndisplacement, network_name))

            nfull_lines = nx_nr // 3
            npartial_lines = int(ceil(nx_nr % 3 / 3.))
            nx_nr_lines = nfull_lines + npartial_lines
            #print("X,Rad - nfull_lines=%s npartial_lines=%s nx_nr_lines=%s\n" % (
                #nfull_lines, npartial_lines, nx_nr_lines))
            n += 1

            Xin = []
            R = []
            lines_full = section[n:n + nx_nr_lines]
            n += nx_nr_lines

            assert len(lines_full) == 7, len(lines_full)

            ipoint = 1
            for line in lines_full:
                if len(line[0:60].strip()) > 0:
                    x1 = double(line[0:10], 'x%i' % ipoint)
                    r1 = double(line[10:20], 'r%i' % ipoint)
                    Xin.append(x1)
                    R.append(r1)
                    ipoint += 1
                else:  # pragma: no cover
                    raise RuntimeError(line.rstrip())

                if len(line[20:60].strip()) > 0:
                    x2 = double(line[20:30], 'x%i' % ipoint)
                    r2 = double(line[30:40], 'r%i' % ipoint)
                    Xin.append(x2)
                    R.append(r2)
                    ipoint += 1

                if len(line[40:60].strip()) > 0:
                    x3 = double(line[40:50], 'x%i' % ipoint)
                    r3 = double(line[50:60], 'r%i' % ipoint)
                    Xin.append(x3)
                    R.append(r3)
                    ipoint += 1
            assert nx_nr == len(Xin), 'nx,nr=%s Xin=%s len(Xin)=%s' % (nx_nr, Xin, len(Xin))

            #----------------------------------------------------
            #print("section[n] = ", section[n].strip())
            ntheta = integer(section[n][0:10], 'ntheta')
            assert ntheta > 0, section[n]
            #print("ntheta = %s" % ntheta)
            nfull_lines = ntheta // 6
            npartial_lines = int(ceil(ntheta % 6 / 6.))
            ntheta_lines = nfull_lines + npartial_lines
            #print("Theta - nfull_lines=%s npartial_lines=%s nlines=%s" % (
            #    nfull_lines, npartial_lines, ntheta_lines))
            n += 1

            lines = section[n:n + ntheta_lines]
            theta = []

            ipoint = 1
            for line in lines:
                #print(line)
                if len(line[0:60].rstrip()) > 0:
                    (theta1) = double(line[0:10], 'theta%i' % ipoint)
                    theta.append(theta1)
                    ipoint += 1
                else:  # pragma: no cover
                    raise RuntimeError(line.rstrip())

                if len(line[0:60].rstrip()) > 0:
                    (theta2) = double(line[10:20], 'theta%i' % ipoint)
                    theta.append(theta2)
                    ipoint += 1

                if len(line[20:60].rstrip()) > 0:
                    (theta3) = double(line[20:30], 'theta%i' % ipoint)
                    theta.append(theta3)
                    ipoint += 1

                if len(line[30:60].rstrip()) > 0:
                    (theta4) = double(line[30:40], 'theta%i' % ipoint)
                    theta.append(theta4)
                    ipoint += 1

                if len(line[40:60].rstrip()) > 0:
                    (theta5) = double(line[40:50], 'theta%i' % ipoint)
                    theta.append(theta5)
                    ipoint += 1

                if len(line[50:60].rstrip()) > 0:
                    (theta6) = double(line[50:60], 'theta%i' % ipoint)
                    theta.append(theta6)
                    ipoint += 1
            n += ntheta_lines

            assert ntheta == len(theta)
            sin_theta_r = [sin(radians(thetai)) for thetai in theta]
            cos_theta_r = [cos(radians(thetai)) for thetai in theta]

            zi = 0.
            # TODO: can't we use numpy meshgrid?
            XYZ = np.zeros([nx_nr, ntheta, 3], dtype='float32')
            #print("Xin=%s \nR=%s" % (Xin, R))
            for (i, x, r) in zip(count(), Xin, R):
                for (j, sin_theta, cos_theta) in zip(count(), sin_theta_r, cos_theta_r):
                    y = r * sin_theta
                    z = r * cos_theta + zi
                    #print("x=%s y=%s z=%s" % (x, y, z))
                    XYZ[i, j, :] = [x, y, z]

            #print("--XYZ--")
            #print(xyz)
            self.add_patch(network_name, kt, cp_norm, XYZ)
        return True