pygeo/parameterization/DVGeo.py
def computeTotalJacobianFD(self, ptSetName, config=None):
        """This function takes the total derivative of an objective,
        I, with respect the points controlled on this processor using FD.
        We take the transpose prodducts and mpi_allreduce them to get the
        resulting value on each processor. Note that this function is slow
        and should eventually be replaced by an analytic version.
        """

        self._finalize()
        self.curPtSet = ptSetName

        if not (self.JT[ptSetName] is None):
            return

        if self.isChild:
            refFFDCoef = copy.copy(self.FFD.coef)
            refCoef = copy.copy(self.coef)

        # Here we set childDelta as False, but it really doesn't matter
        # whether it is True or False because we take a difference
        # between coordsph and coords0, so the Xstart would be cancelled
        # out in the end.
        coords0 = self.update(ptSetName, childDelta=False, config=config).flatten()

        if self.nPts[ptSetName] is None:
            self.nPts[ptSetName] = len(coords0.flatten())
        for child in self.children:
            child.nPts[ptSetName] = self.nPts[ptSetName]

        DVGlobalCount, DVLocalCount, DVSecLocCount, DVSpanLocCount = self._getDVOffsets()

        h = 1e-6

        self.JT[ptSetName] = np.zeros([self.nDV_T, self.nPts[ptSetName]])

        for key in self.DV_listGlobal:
            for j in range(self.DV_listGlobal[key].nVal):
                if self.isChild:
                    self.FFD.coef = refFFDCoef.copy()
                    self.coef = refCoef.copy()
                    self.refAxis.coef = refCoef.copy()
                    self.refAxis._updateCurveCoef()

                refVal = self.DV_listGlobal[key].value[j]

                self.DV_listGlobal[key].value[j] += h

                coordsph = self.update(ptSetName, childDelta=False, config=config).flatten()

                deriv = (coordsph - coords0) / h
                self.JT[ptSetName][DVGlobalCount, :] = deriv

                DVGlobalCount += 1
                self.DV_listGlobal[key].value[j] = refVal

        for key in self.DV_listSpanwiseLocal:
            for j in range(self.DV_listSpanwiseLocal[key].nVal):
                if self.isChild:
                    self.FFD.coef = refFFDCoef.copy()
                    self.coef = refCoef.copy()
                    self.refAxis.coef = refCoef.copy()
                    self.refAxis._updateCurveCoef()

                refVal = self.DV_listSpanwiseLocal[key].value[j]

                self.DV_listSpanwiseLocal[key].value[j] += h
                coordsph = self.update(ptSetName, childDelta=False, config=config).flatten()

                deriv = (coordsph - coords0) / h
                self.JT[ptSetName][DVSpanLocCount, :] = deriv

                DVSpanLocCount += 1
                self.DV_listSpanwiseLocal[key].value[j] = refVal

        for key in self.DV_listSectionLocal:
            for j in range(self.DV_listSectionLocal[key].nVal):
                if self.isChild:
                    self.FFD.coef = refFFDCoef.copy()
                    self.coef = refCoef.copy()
                    self.refAxis.coef = refCoef.copy()
                    self.refAxis._updateCurveCoef()

                refVal = self.DV_listSectionLocal[key].value[j]

                self.DV_listSectionLocal[key].value[j] += h
                coordsph = self.update(ptSetName, childDelta=False, config=config).flatten()

                deriv = (coordsph - coords0) / h
                self.JT[ptSetName][DVSecLocCount, :] = deriv

                DVSecLocCount += 1
                self.DV_listSectionLocal[key].value[j] = refVal

        for key in self.DV_listLocal:
            for j in range(self.DV_listLocal[key].nVal):
                if self.isChild:
                    self.FFD.coef = refFFDCoef.copy()
                    self.coef = refCoef.copy()
                    self.refAxis.coef = refCoef.copy()
                    self.refAxis._updateCurveCoef()

                refVal = self.DV_listLocal[key].value[j]

                self.DV_listLocal[key].value[j] += h
                coordsph = self.update(ptSetName, childDelta=False, config=config).flatten()

                deriv = (coordsph - coords0) / h
                self.JT[ptSetName][DVLocalCount, :] = deriv

                DVLocalCount += 1
                self.DV_listLocal[key].value[j] = refVal

        for iChild in range(len(self.children)):
            child = self.children[iChild]
            child._finalize()

            # In the updates applied previously, the FFD points on the children
            # will have been set as deltas. We need to set them as absolute
            # coordinates based on the changes in the parent before moving down
            # to the next level
            self.applyToChild(iChild)

            # Now get jacobian from child and add to parent jacobian
            child.computeTotalJacobianFD(ptSetName, config=config)
            self.JT[ptSetName] = self.JT[ptSetName] + child.JT[ptSetName]

        return
This function takes the total derivative of an objective,
        I, with respect the points controlled on this processor using FD.
        We take the transpose prodducts and mpi_allreduce them to get the
        resulting value on each processor. Note that this function is slow
        and should eventually be replaced by an analytic version.
        
This function takes the total derivative of an objective,
I, with respect the points controlled on this processor using FD.
We take the transpose prodducts and mpi_allreduce them to get the
resulting value on each processor. Note that this function is slow
and should eventually be replaced by an analytic version.
This function takes the total derivative of an objective I with respect the points controlled on this processor using FD . We take the transpose prodducts and mpi_allreduce them to get the resulting value on each processor . Note that this function is slow and should eventually be replaced by an analytic version .
def computeTotalJacobianFD(self, ptSetName, config=None):
        self._finalize()
        self.curPtSet = ptSetName
        if not (self.JT[ptSetName] is None):
            return
        if self.isChild:
            refFFDCoef = copy.copy(self.FFD.coef)
            refCoef = copy.copy(self.coef)
        coords0 = self.update(ptSetName, childDelta=False, config=config).flatten()
        if self.nPts[ptSetName] is None:
            self.nPts[ptSetName] = len(coords0.flatten())
        for child in self.children:
            child.nPts[ptSetName] = self.nPts[ptSetName]
        DVGlobalCount, DVLocalCount, DVSecLocCount, DVSpanLocCount = self._getDVOffsets()
        h = 1e-6
        self.JT[ptSetName] = np.zeros([self.nDV_T, self.nPts[ptSetName]])
        for key in self.DV_listGlobal:
            for j in range(self.DV_listGlobal[key].nVal):
                if self.isChild:
                    self.FFD.coef = refFFDCoef.copy()
                    self.coef = refCoef.copy()
                    self.refAxis.coef = refCoef.copy()
                    self.refAxis._updateCurveCoef()
                refVal = self.DV_listGlobal[key].value[j]
                self.DV_listGlobal[key].value[j] += h
                coordsph = self.update(ptSetName, childDelta=False, config=config).flatten()
                deriv = (coordsph - coords0) / h
                self.JT[ptSetName][DVGlobalCount, :] = deriv
                DVGlobalCount += 1
                self.DV_listGlobal[key].value[j] = refVal
        for key in self.DV_listSpanwiseLocal:
            for j in range(self.DV_listSpanwiseLocal[key].nVal):
                if self.isChild:
                    self.FFD.coef = refFFDCoef.copy()
                    self.coef = refCoef.copy()
                    self.refAxis.coef = refCoef.copy()
                    self.refAxis._updateCurveCoef()
                refVal = self.DV_listSpanwiseLocal[key].value[j]
                self.DV_listSpanwiseLocal[key].value[j] += h
                coordsph = self.update(ptSetName, childDelta=False, config=config).flatten()
                deriv = (coordsph - coords0) / h
                self.JT[ptSetName][DVSpanLocCount, :] = deriv
                DVSpanLocCount += 1
                self.DV_listSpanwiseLocal[key].value[j] = refVal
        for key in self.DV_listSectionLocal:
            for j in range(self.DV_listSectionLocal[key].nVal):
                if self.isChild:
                    self.FFD.coef = refFFDCoef.copy()
                    self.coef = refCoef.copy()
                    self.refAxis.coef = refCoef.copy()
                    self.refAxis._updateCurveCoef()
                refVal = self.DV_listSectionLocal[key].value[j]
                self.DV_listSectionLocal[key].value[j] += h
                coordsph = self.update(ptSetName, childDelta=False, config=config).flatten()
                deriv = (coordsph - coords0) / h
                self.JT[ptSetName][DVSecLocCount, :] = deriv
                DVSecLocCount += 1
                self.DV_listSectionLocal[key].value[j] = refVal
        for key in self.DV_listLocal:
            for j in range(self.DV_listLocal[key].nVal):
                if self.isChild:
                    self.FFD.coef = refFFDCoef.copy()
                    self.coef = refCoef.copy()
                    self.refAxis.coef = refCoef.copy()
                    self.refAxis._updateCurveCoef()
                refVal = self.DV_listLocal[key].value[j]
                self.DV_listLocal[key].value[j] += h
                coordsph = self.update(ptSetName, childDelta=False, config=config).flatten()
                deriv = (coordsph - coords0) / h
                self.JT[ptSetName][DVLocalCount, :] = deriv
                DVLocalCount += 1
                self.DV_listLocal[key].value[j] = refVal
        for iChild in range(len(self.children)):
            child = self.children[iChild]
            child._finalize()
            self.applyToChild(iChild)
            child.computeTotalJacobianFD(ptSetName, config=config)
            self.JT[ptSetName] = self.JT[ptSetName] + child.JT[ptSetName]
        return
def computeTotalJacobianFD ( self , ptSetName , config = None ) : self . _finalize ( ) self . curPtSet = ptSetName if not ( self . JT [ ptSetName ] is None ) : return if self . isChild : refFFDCoef = copy . copy ( self . FFD . coef ) refCoef = copy . copy ( self . coef ) coords0 = self . update ( ptSetName , childDelta = False , config = config ) . flatten ( ) if self . nPts [ ptSetName ] is None : self . nPts [ ptSetName ] = len ( coords0 . flatten ( ) ) for child in self . children : child . nPts [ ptSetName ] = self . nPts [ ptSetName ] DVGlobalCount , DVLocalCount , DVSecLocCount , DVSpanLocCount = self . _getDVOffsets ( ) h = 1e-6 self . JT [ ptSetName ] = np . zeros ( [ self . nDV_T , self . nPts [ ptSetName ] ] ) for key in self . DV_listGlobal : for j in range ( self . DV_listGlobal [ key ] . nVal ) : if self . isChild : self . FFD . coef = refFFDCoef . copy ( ) self . coef = refCoef . copy ( ) self . refAxis . coef = refCoef . copy ( ) self . refAxis . _updateCurveCoef ( ) refVal = self . DV_listGlobal [ key ] . value [ j ] self . DV_listGlobal [ key ] . value [ j ] += h coordsph = self . update ( ptSetName , childDelta = False , config = config ) . flatten ( ) deriv = ( coordsph - coords0 ) / h self . JT [ ptSetName ] [ DVGlobalCount , : ] = deriv DVGlobalCount += 1 self . DV_listGlobal [ key ] . value [ j ] = refVal for key in self . DV_listSpanwiseLocal : for j in range ( self . DV_listSpanwiseLocal [ key ] . nVal ) : if self . isChild : self . FFD . coef = refFFDCoef . copy ( ) self . coef = refCoef . copy ( ) self . refAxis . coef = refCoef . copy ( ) self . refAxis . _updateCurveCoef ( ) refVal = self . DV_listSpanwiseLocal [ key ] . value [ j ] self . DV_listSpanwiseLocal [ key ] . value [ j ] += h coordsph = self . update ( ptSetName , childDelta = False , config = config ) . flatten ( ) deriv = ( coordsph - coords0 ) / h self . JT [ ptSetName ] [ DVSpanLocCount , : ] = deriv DVSpanLocCount += 1 self . DV_listSpanwiseLocal [ key ] . value [ j ] = refVal for key in self . DV_listSectionLocal : for j in range ( self . DV_listSectionLocal [ key ] . nVal ) : if self . isChild : self . FFD . coef = refFFDCoef . copy ( ) self . coef = refCoef . copy ( ) self . refAxis . coef = refCoef . copy ( ) self . refAxis . _updateCurveCoef ( ) refVal = self . DV_listSectionLocal [ key ] . value [ j ] self . DV_listSectionLocal [ key ] . value [ j ] += h coordsph = self . update ( ptSetName , childDelta = False , config = config ) . flatten ( ) deriv = ( coordsph - coords0 ) / h self . JT [ ptSetName ] [ DVSecLocCount , : ] = deriv DVSecLocCount += 1 self . DV_listSectionLocal [ key ] . value [ j ] = refVal for key in self . DV_listLocal : for j in range ( self . DV_listLocal [ key ] . nVal ) : if self . isChild : self . FFD . coef = refFFDCoef . copy ( ) self . coef = refCoef . copy ( ) self . refAxis . coef = refCoef . copy ( ) self . refAxis . _updateCurveCoef ( ) refVal = self . DV_listLocal [ key ] . value [ j ] self . DV_listLocal [ key ] . value [ j ] += h coordsph = self . update ( ptSetName , childDelta = False , config = config ) . flatten ( ) deriv = ( coordsph - coords0 ) / h self . JT [ ptSetName ] [ DVLocalCount , : ] = deriv DVLocalCount += 1 self . DV_listLocal [ key ] . value [ j ] = refVal for iChild in range ( len ( self . children ) ) : child = self . children [ iChild ] child . _finalize ( ) self . applyToChild ( iChild ) child . computeTotalJacobianFD ( ptSetName , config = config ) self . JT [ ptSetName ] = self . JT [ ptSetName ] + child . JT [ ptSetName ] return
This function takes the total derivative of an objective,
I, with respect the points controlled on this processor using FD.
This function takes the total derivative of an objective I with respect the points controlled on this processor using FD .
"""This function takes the total derivative of an objective,
        I, with respect the points controlled on this processor using FD.
        We take the transpose prodducts and mpi_allreduce them to get the
        resulting value on each processor. Note that this function is slow
        and should eventually be replaced by an analytic version.
        """ # Here we set childDelta as False, but it really doesn't matter # whether it is True or False because we take a difference # between coordsph and coords0, so the Xstart would be cancelled # out in the end. # In the updates applied previously, the FFD points on the children # will have been set as deltas. We need to set them as absolute # coordinates based on the changes in the parent before moving down # to the next level # Now get jacobian from child and add to parent jacobian
self
ptSetName
config