pygeo/parameterization/DVGeo.py
def _update_deriv(self, iDV=0, h=1.0e-40j, oneoverh=1.0 / 1e-40, config=None, localDV=False):

        """Copy of update function for derivative calc"""
        new_pts = np.zeros((self.nPtAttach, 3), "D")

        # Step 1: Call all the design variables IFF we have ref axis:
        if len(self.axis) > 0:

            # Recompute changes due to global dvs at current point + h
            self.updateCalculations(new_pts, isComplex=True, config=config)

            # create a vector of the size of the full FFD
            np.put(self.FFD.coef[:, 0], self.ptAttachInd, new_pts[:, 0])
            np.put(self.FFD.coef[:, 1], self.ptAttachInd, new_pts[:, 1])
            np.put(self.FFD.coef[:, 2], self.ptAttachInd, new_pts[:, 2])

            # Add dependence of section variables on the global dv rotations
            for key in self.DV_listSectionLocal:
                self.DV_listSectionLocal[key].updateComplex(self.FFD.coef, self.coefRotM, config)

            # Send values back to new_pts
            new_pts[:, 0] = self.FFD.coef[self.ptAttachInd, 0]
            new_pts[:, 1] = self.FFD.coef[self.ptAttachInd, 1]
            new_pts[:, 2] = self.FFD.coef[self.ptAttachInd, 2]

            # set the forward effect of the global design vars in each child
            for iChild in range(len(self.children)):

                # get the derivative of the child axis and control points wrt the parent
                # control points
                dXrefdCoef = self.FFD.embededVolumes["child%d_axis" % (iChild)].dPtdCoef
                dCcdCoef = self.FFD.embededVolumes["child%d_coef" % (iChild)].dPtdCoef

                # create a vector with the derivative of the parent control points wrt the
                # parent global variables
                tmp = np.zeros(self.FFD.coef.shape, dtype="d")
                np.put(tmp[:, 0], self.ptAttachInd, np.imag(new_pts[:, 0]) * oneoverh)
                np.put(tmp[:, 1], self.ptAttachInd, np.imag(new_pts[:, 1]) * oneoverh)
                np.put(tmp[:, 2], self.ptAttachInd, np.imag(new_pts[:, 2]) * oneoverh)

                # create variables for the total derivative of the child axis and control
                # points wrt the parent global variables
                dXrefdXdv = np.zeros((dXrefdCoef.shape[0] * 3), "d")
                dCcdXdv = np.zeros((dCcdCoef.shape[0] * 3), "d")

                # multiply the derivative of the child axis wrt the parent control points
                # by the derivative of the parent control points wrt the parent global vars.
                # this is just chain rule
                dXrefdXdv[0::3] = dXrefdCoef.dot(tmp[:, 0])
                dXrefdXdv[1::3] = dXrefdCoef.dot(tmp[:, 1])
                dXrefdXdv[2::3] = dXrefdCoef.dot(tmp[:, 2])

                # do the same for the child control points
                dCcdXdv[0::3] = dCcdCoef.dot(tmp[:, 0])
                dCcdXdv[1::3] = dCcdCoef.dot(tmp[:, 1])
                dCcdXdv[2::3] = dCcdCoef.dot(tmp[:, 2])
                if localDV and self._getNDVLocalSelf():
                    self.children[iChild].dXrefdXdvl[:, iDV] += dXrefdXdv
                    self.children[iChild].dCcdXdvl[:, iDV] += dCcdXdv
                elif self._getNDVGlobalSelf():
                    self.children[iChild].dXrefdXdvg[:, iDV] += dXrefdXdv.real
                    self.children[iChild].dCcdXdvg[:, iDV] += dCcdXdv.real
        return new_pts
Copy of update function for derivative calc
Copy of update function for derivative calc
Copy of update function for derivative calc
def _update_deriv(self, iDV=0, h=1.0e-40j, oneoverh=1.0 / 1e-40, config=None, localDV=False):
        new_pts = np.zeros((self.nPtAttach, 3), "D")
        if len(self.axis) > 0:
            self.updateCalculations(new_pts, isComplex=True, config=config)
            np.put(self.FFD.coef[:, 0], self.ptAttachInd, new_pts[:, 0])
            np.put(self.FFD.coef[:, 1], self.ptAttachInd, new_pts[:, 1])
            np.put(self.FFD.coef[:, 2], self.ptAttachInd, new_pts[:, 2])
            for key in self.DV_listSectionLocal:
                self.DV_listSectionLocal[key].updateComplex(self.FFD.coef, self.coefRotM, config)
            new_pts[:, 0] = self.FFD.coef[self.ptAttachInd, 0]
            new_pts[:, 1] = self.FFD.coef[self.ptAttachInd, 1]
            new_pts[:, 2] = self.FFD.coef[self.ptAttachInd, 2]
            for iChild in range(len(self.children)):
                dXrefdCoef = self.FFD.embededVolumes["child%d_axis" % (iChild)].dPtdCoef
                dCcdCoef = self.FFD.embededVolumes["child%d_coef" % (iChild)].dPtdCoef
                tmp = np.zeros(self.FFD.coef.shape, dtype="d")
                np.put(tmp[:, 0], self.ptAttachInd, np.imag(new_pts[:, 0]) * oneoverh)
                np.put(tmp[:, 1], self.ptAttachInd, np.imag(new_pts[:, 1]) * oneoverh)
                np.put(tmp[:, 2], self.ptAttachInd, np.imag(new_pts[:, 2]) * oneoverh)
                dXrefdXdv = np.zeros((dXrefdCoef.shape[0] * 3), "d")
                dCcdXdv = np.zeros((dCcdCoef.shape[0] * 3), "d")
                dXrefdXdv[0::3] = dXrefdCoef.dot(tmp[:, 0])
                dXrefdXdv[1::3] = dXrefdCoef.dot(tmp[:, 1])
                dXrefdXdv[2::3] = dXrefdCoef.dot(tmp[:, 2])
                dCcdXdv[0::3] = dCcdCoef.dot(tmp[:, 0])
                dCcdXdv[1::3] = dCcdCoef.dot(tmp[:, 1])
                dCcdXdv[2::3] = dCcdCoef.dot(tmp[:, 2])
                if localDV and self._getNDVLocalSelf():
                    self.children[iChild].dXrefdXdvl[:, iDV] += dXrefdXdv
                    self.children[iChild].dCcdXdvl[:, iDV] += dCcdXdv
                elif self._getNDVGlobalSelf():
                    self.children[iChild].dXrefdXdvg[:, iDV] += dXrefdXdv.real
                    self.children[iChild].dCcdXdvg[:, iDV] += dCcdXdv.real
        return new_pts
def _update_deriv ( self , iDV = 0 , h = 1.0e-40j , oneoverh = 1.0 / 1e-40 , config = None , localDV = False ) : new_pts = np . zeros ( ( self . nPtAttach , 3 ) , "D" ) if len ( self . axis ) > 0 : self . updateCalculations ( new_pts , isComplex = True , config = config ) np . put ( self . FFD . coef [ : , 0 ] , self . ptAttachInd , new_pts [ : , 0 ] ) np . put ( self . FFD . coef [ : , 1 ] , self . ptAttachInd , new_pts [ : , 1 ] ) np . put ( self . FFD . coef [ : , 2 ] , self . ptAttachInd , new_pts [ : , 2 ] ) for key in self . DV_listSectionLocal : self . DV_listSectionLocal [ key ] . updateComplex ( self . FFD . coef , self . coefRotM , config ) new_pts [ : , 0 ] = self . FFD . coef [ self . ptAttachInd , 0 ] new_pts [ : , 1 ] = self . FFD . coef [ self . ptAttachInd , 1 ] new_pts [ : , 2 ] = self . FFD . coef [ self . ptAttachInd , 2 ] for iChild in range ( len ( self . children ) ) : dXrefdCoef = self . FFD . embededVolumes [ "child%d_axis" % ( iChild ) ] . dPtdCoef dCcdCoef = self . FFD . embededVolumes [ "child%d_coef" % ( iChild ) ] . dPtdCoef tmp = np . zeros ( self . FFD . coef . shape , dtype = "d" ) np . put ( tmp [ : , 0 ] , self . ptAttachInd , np . imag ( new_pts [ : , 0 ] ) * oneoverh ) np . put ( tmp [ : , 1 ] , self . ptAttachInd , np . imag ( new_pts [ : , 1 ] ) * oneoverh ) np . put ( tmp [ : , 2 ] , self . ptAttachInd , np . imag ( new_pts [ : , 2 ] ) * oneoverh ) dXrefdXdv = np . zeros ( ( dXrefdCoef . shape [ 0 ] * 3 ) , "d" ) dCcdXdv = np . zeros ( ( dCcdCoef . shape [ 0 ] * 3 ) , "d" ) dXrefdXdv [ 0 : : 3 ] = dXrefdCoef . dot ( tmp [ : , 0 ] ) dXrefdXdv [ 1 : : 3 ] = dXrefdCoef . dot ( tmp [ : , 1 ] ) dXrefdXdv [ 2 : : 3 ] = dXrefdCoef . dot ( tmp [ : , 2 ] ) dCcdXdv [ 0 : : 3 ] = dCcdCoef . dot ( tmp [ : , 0 ] ) dCcdXdv [ 1 : : 3 ] = dCcdCoef . dot ( tmp [ : , 1 ] ) dCcdXdv [ 2 : : 3 ] = dCcdCoef . dot ( tmp [ : , 2 ] ) if localDV and self . _getNDVLocalSelf ( ) : self . children [ iChild ] . dXrefdXdvl [ : , iDV ] += dXrefdXdv self . children [ iChild ] . dCcdXdvl [ : , iDV ] += dCcdXdv elif self . _getNDVGlobalSelf ( ) : self . children [ iChild ] . dXrefdXdvg [ : , iDV ] += dXrefdXdv . real self . children [ iChild ] . dCcdXdvg [ : , iDV ] += dCcdXdv . real return new_pts
Copy of update function for derivative calc
Copy of update function for derivative calc
"""Copy of update function for derivative calc""" # Step 1: Call all the design variables IFF we have ref axis: # Recompute changes due to global dvs at current point + h # create a vector of the size of the full FFD # Add dependence of section variables on the global dv rotations # Send values back to new_pts # set the forward effect of the global design vars in each child # get the derivative of the child axis and control points wrt the parent # control points # create a vector with the derivative of the parent control points wrt the # parent global variables # create variables for the total derivative of the child axis and control # points wrt the parent global variables # multiply the derivative of the child axis wrt the parent control points # by the derivative of the parent control points wrt the parent global vars. # this is just chain rule # do the same for the child control points
self
iDV
h
oneoverh
config
localDV