コード例 #1
0
    def _get_Q(self, ms, ns, P0):
        nsurf = ns.shape[0]

        Ps = []
        for i in xrange(nsurf):
            P = numpy.zeros((ns[i] + 1, 4, 3), order='F')
            for j in xrange(4):
                P[:, j, :] = P0[sum(ns[:i]):sum(ns[:i + 1]) + 1, :]
                P[:, j, 2] = j
            Ps.append(P)

        bse = BSEmodel(Ps)
        for i in xrange(nsurf):
            bse.set_bspline_option('num_cp', i, 'u', ms[i] + 1)
            bse.set_bspline_option('num_pt', i, 'u', ns[i] + 1)
            bse.set_bspline_option('num_pt', i, 'v', 4)
        bse.assemble()
        cp = bse.vec['cp_str'].array
        pt = bse.vec['pt_str'].array
        jac = bse.jac['d(pt_str)/d(cp_str)']

        for i in xrange(nsurf):
            bse.vec['pt_str'].surfs[i][:, :, :] = Ps[i]
        mtx = jac.T.dot(jac)
        rhs = jac.T.dot(pt)
        for dim in xrange(3):
            cp[:, dim] = scipy.sparse.linalg.cg(mtx, rhs[:, dim])[0]

        Q = numpy.zeros((sum(ms) + 1, 3), order='F')
        for i in xrange(nsurf):
            Q[sum(ms[:i]):sum(ms[:i+1])+1,:] = \
                bse.vec['cp_str'].surfs[i][:,0,:]
        return Q
コード例 #2
0
ファイル: PGMwing.py プロジェクト: Heathckliff/GeoMACH
    def _get_Q(self, ms, ns, P0):
        nsurf = ns.shape[0]

        Ps = []
        for i in xrange(nsurf):
            P = numpy.zeros((ns[i]+1,4,3), order='F')
            for j in xrange(4):
                P[:,j,:] = P0[sum(ns[:i]):sum(ns[:i+1])+1,:]
                P[:,j,2] = j
            Ps.append(P)

        bse = BSEmodel(Ps)
        for i in xrange(nsurf):
            bse.set_bspline_option('num_cp', i, 'u', ms[i]+1)
            bse.set_bspline_option('num_pt', i, 'u', ns[i]+1)
            bse.set_bspline_option('num_pt', i, 'v', 4)
        bse.assemble()
        cp = bse.vec['cp_str'].array
        pt = bse.vec['pt_str'].array
        jac = bse.jac['d(pt_str)/d(cp_str)']

        for i in xrange(nsurf):
            bse.vec['pt_str'].surfs[i][:,:,:] = Ps[i]
        mtx = jac.T.dot(jac)
        rhs = jac.T.dot(pt)
        for dim in xrange(3):
            cp[:, dim] = scipy.sparse.linalg.cg(mtx, rhs[:, dim])[0]

        Q = numpy.zeros((sum(ms) + 1,3),order='F')
        for i in xrange(nsurf):
            Q[sum(ms[:i]):sum(ms[:i+1])+1,:] = \
                bse.vec['cp_str'].surfs[i][:,0,:]
        return Q
コード例 #3
0
ファイル: PGMconfiguration.py プロジェクト: gjkennedy/GeoMACH
    def _initialize_bse(self):
        """ 
        Instantiates and sets up BSE model. 5 steps:

        1. Recursively loops over comps' faces' surfs' to
           collect initial list of surfaces from each surf
           and give each surface a unique global index
        2. Instantiates BSE B-spline surface model
        3. Components set differentiability options
        4. Set user-specified B-spline options
        5. Assemble BSE Jacobians
        """
        surf_index = 0
        surfs_list = []
        for comp in self.comps.values():
            surf_index = comp.initialize_bse(surfs_list, surf_index)

        self._bse = BSEmodel(surfs_list)

        bse = self._bse

        comp_num = 0
        for comp_name in self.comps:
            comp = self.comps[comp_name]
            comp.set_info(comp_name, comp_num, bse)
            comp.set_diff()
            comp.set_hidden_surfaces()
            comp_num += 1
        self._set_bspline_options()

        for isurf in range(len(surfs_list)):
            surf = surfs_list[isurf]
            if numpy.average(surf[:, :, 2]) < 0:
                bse.hidden[isurf] = True

        bse.assemble()
コード例 #4
0
    def _get_P(self, nP, airfoils, name, bunch_LE, bunch_TE):
        def bunch_start(ind, a):
            ind[:] = ind**a

        def bunch_end(ind, a):
            ind[:] = 1 - (1 - ind)**a

        airfoil = airfoils[name]

        P = numpy.zeros((airfoil.shape[0], 4, 3), order='F')
        for j in range(4):
            P[:, j, :2] = airfoil[:, :]
            P[:, j, 2] = j
        bse = BSEmodel([P])

        bse.set_bspline_option('num_pt', 0, 'u', airfoil.shape[0])
        bse.set_bspline_option('num_cp', 0, 'u', int(airfoil.shape[0] / 3))
        bse.set_bspline_option('num_pt', 0, 'v', 4)
        bse.set_bspline_option('num_cp', 0, 'v', 4)
        bse.assemble()
        cp = bse.vec['cp_str'].array
        pt = bse.vec['pt_str'].array
        jac = bse.jac['d(pt_str)/d(cp_str)']

        bse.vec['pt_str'].surfs[0][:, :, :] = P
        mtx = jac.T.dot(jac)
        rhs = jac.T.dot(pt)
        for dim in xrange(3):
            cp[:, dim] = scipy.sparse.linalg.cg(mtx, rhs[:, dim])[0]
        fit = numpy.array(cp)

        bse.set_bspline_option('num_pt', 0, 'u', nP)
        bse.assemble()
        cp = bse.vec['cp_str'].array
        pt = bse.vec['pt_str'].array

        cp[:, :] = fit[:, :]
        surfs = numpy.zeros(nP).astype(int)
        ind_u = numpy.linspace(0, 1, nP)
        if name == 'upp':
            bunch_start(ind_u, bunch_TE)
            bunch_end(ind_u, bunch_LE)
        elif name == 'low':
            bunch_start(ind_u, bunch_LE)
            bunch_end(ind_u, bunch_TE)
        ind_v = numpy.zeros(nP)
        bse.add_jacobian('new', surfs, ind_u, ind_v, 3)
        bse.apply_jacobian('new', 'd(new)/d(cp_str)', 'cp_str')

        return bse.vec['new'].array[:, :]
コード例 #5
0
ファイル: PGMwing.py プロジェクト: Heathckliff/GeoMACH
    def _get_P(self, nP, airfoils, name, bunch_LE, bunch_TE):
        def bunch_start(ind, a):
            ind[:] = ind**a
        def bunch_end(ind, a):
            ind[:] = 1 - (1-ind)**a

        airfoil = airfoils[name]

        P = numpy.zeros((airfoil.shape[0],4,3),order='F')
        for j in range(4):
            P[:,j,:2] = airfoil[:,:]
            P[:,j,2] = j
        bse = BSEmodel([P])

        bse.set_bspline_option('num_pt', 0, 'u', 
                               airfoil.shape[0])
        bse.set_bspline_option('num_cp', 0, 'u', 
                               int(airfoil.shape[0]/3))
        bse.set_bspline_option('num_pt', 0, 'v', 4)
        bse.set_bspline_option('num_cp', 0, 'v', 4)
        bse.assemble()
        cp = bse.vec['cp_str'].array
        pt = bse.vec['pt_str'].array
        jac = bse.jac['d(pt_str)/d(cp_str)']

        bse.vec['pt_str'].surfs[0][:, :, :] = P
        mtx = jac.T.dot(jac)
        rhs = jac.T.dot(pt)
        for dim in xrange(3):
            cp[:, dim] = scipy.sparse.linalg.cg(mtx, rhs[:, dim])[0]
        fit = numpy.array(cp)

        bse.set_bspline_option('num_pt', 0, 'u', nP)
        bse.assemble()
        cp = bse.vec['cp_str'].array
        pt = bse.vec['pt_str'].array

        cp[:, :] = fit[:, :]
        surfs = numpy.zeros(nP).astype(int)
        ind_u = numpy.linspace(0, 1, nP)
        if name == 'upp':
            bunch_start(ind_u, bunch_TE)
            bunch_end(ind_u, bunch_LE)
        elif name == 'low':
            bunch_start(ind_u, bunch_LE)
            bunch_end(ind_u, bunch_TE)
        ind_v = numpy.zeros(nP)
        bse.add_jacobian('new', surfs, ind_u, ind_v, 3)
        bse.apply_jacobian('new', 'd(new)/d(cp_str)', 'cp_str')

        return bse.vec['new'].array[:, :]
コード例 #6
0
    def _get_P(self, nP, airfoil):
        P = numpy.zeros((airfoil.shape[0],4,3),order='F')
        for j in range(4):
            P[:,j,:2] = airfoil[:,:]
            P[:,j,2] = j
        bse = BSEmodel([P])

        bse.set_bspline_option('num_pt', 0, 'u', 
                               airfoil.shape[0])
        bse.set_bspline_option('num_cp', 0, 'u', 
                               int(airfoil.shape[0]/3))
        bse.set_bspline_option('num_pt', 0, 'v', 4)
        bse.set_bspline_option('num_cp', 0, 'v', 4)
        bse.assemble()
        cp = bse.vec['cp_str'].array
        pt = bse.vec['pt_str'].array
        jac = bse.jac['d(pt_str)/d(cp_str)']

        bse.vec['pt_str'].surfs[0][:, :, :] = P
        mtx = jac.T.dot(jac)
        rhs = jac.T.dot(pt)
        for dim in xrange(3):
            cp[:, dim] = scipy.sparse.linalg.cg(mtx, rhs[:, dim])[0]
        fit = numpy.array(cp)

        bse.set_bspline_option('num_pt', 0, 'u', nP)
        bse.assemble()
        cp = bse.vec['cp_str'].array
        pt = bse.vec['pt_str'].array

        cp[:, :] = fit[:, :]
        bse.apply_jacobian('pt_str', 'd(pt_str)/d(cp_str)', 'cp_str')

        return bse.vec['pt_str'].surfs[0][:, 0, :]