pygeo/parameterization/DVGeo.py
def updateCalculations(self, new_pts, isComplex, config):
        """
        The core update rountine. pulled out here to eliminate duplication between update and
        update_deriv.
        """

        if self.isChild:
            # If this is a child, update the links between the ref axis and the
            # coefficients on the nested FFD now that the nested FFD has been
            # moved.
            # **Important**: this expects the FFD coef to be clean on this level,
            # meaning that the only changes to FFD.coef can be coming from
            # higher levels.

            # just use complex dtype here. we will convert to real in the end
            self.links_x = self.links_x.astype("D")

            for ipt in range(self.nPtAttach):
                base_pt = self.refAxis.curves[self.curveIDs[ipt]](self.links_s[ipt])
                self.links_x[ipt] = self.FFD.coef[self.ptAttachInd[ipt], :] - base_pt

        # Run Global Design Vars
        for key in self.DV_listGlobal:
            self.DV_listGlobal[key](self, config)

        # update the reference axis now that the new global vars have been run
        self.refAxis.coef = self.coef.copy()
        self.refAxis._updateCurveCoef()

        for ipt in range(self.nPtAttach):
            base_pt = self.refAxis.curves[self.curveIDs[ipt]](self.links_s[ipt])
            # Variables for rotType = 0 rotation + scaling
            ang = self.axis[self.curveIDNames[ipt]]["rot0ang"]
            ax_dir = self.axis[self.curveIDNames[ipt]]["rot0axis"]

            scale = self.scale[self.curveIDNames[ipt]](self.links_s[ipt])
            scale_x = self.scale_x[self.curveIDNames[ipt]](self.links_s[ipt])
            scale_y = self.scale_y[self.curveIDNames[ipt]](self.links_s[ipt])
            scale_z = self.scale_z[self.curveIDNames[ipt]](self.links_s[ipt])

            rotType = self.axis[self.curveIDNames[ipt]]["rotType"]
            if rotType == 0:
                bp_ = np.copy(base_pt)  # copy of original pointset - will not be rotated
                if isinstance(ang, (float, int)):  # rotation active only if a non-default value is provided
                    ang *= np.pi / 180  # conv to [rad]
                    # Rotating the FFD according to inputs
                    # The FFD points should now be aligned with the main system of reference
                    base_pt = geo_utils.rotVbyW(bp_, ax_dir, ang)
                deriv = self.refAxis.curves[self.curveIDs[ipt]].getDerivative(self.links_s[ipt])
                deriv /= geo_utils.euclideanNorm(deriv)  # Normalize
                new_vec = -np.cross(deriv, self.links_n[ipt])
                if isComplex:
                    new_pts[ipt] = bp_ + new_vec * scale  # using "unrotated" bp_ vector
                else:
                    new_pts[ipt] = np.real(bp_ + new_vec * scale)

                if isinstance(ang, (float, int)):
                    # Rotating to be aligned with main sys ref
                    nv_ = np.copy(new_vec)
                    new_vec = geo_utils.rotVbyW(nv_, ax_dir, ang)

                # Apply scaling
                new_vec[0] *= scale_x
                new_vec[1] *= scale_y
                new_vec[2] *= scale_z

                if isinstance(ang, (float, int)):
                    # Rotating back the scaled pointset to its original position
                    nv_rot = np.copy(new_vec)  # nv_rot is scaled and rotated
                    new_vec = geo_utils.rotVbyW(nv_rot, ax_dir, -ang)

                new_vec = geo_utils.rotVbyW(
                    new_vec, deriv, self.rot_theta[self.curveIDNames[ipt]](self.links_s[ipt]) * np.pi / 180
                )

                if isComplex:
                    new_pts[ipt] = bp_ + new_vec
                else:
                    new_pts[ipt] = np.real(bp_ + new_vec)

            else:
                rotX = geo_utils.rotxM(self.rot_x[self.curveIDNames[ipt]](self.links_s[ipt]))
                rotY = geo_utils.rotyM(self.rot_y[self.curveIDNames[ipt]](self.links_s[ipt]))
                rotZ = geo_utils.rotzM(self.rot_z[self.curveIDNames[ipt]](self.links_s[ipt]))

                D = self.links_x[ipt]

                rotM = self._getRotMatrix(rotX, rotY, rotZ, rotType)

                # if necessary, assign rotation matrix for each ffd coef
                if self.coefRotM is not None:
                    attachedPoint = self.ptAttachInd[ipt]
                    if isComplex:
                        self.coefRotM[attachedPoint] = rotM
                    else:
                        self.coefRotM[attachedPoint] = np.real(rotM)

                D = np.dot(rotM, D)
                if rotType == 7:
                    # only apply the theta rotations in certain cases
                    deriv = self.refAxis.curves[self.curveIDs[ipt]].getDerivative(self.links_s[ipt])
                    deriv /= geo_utils.euclideanNorm(deriv)  # Normalize
                    D = geo_utils.rotVbyW(
                        D, deriv, np.pi / 180 * self.rot_theta[self.curveIDNames[ipt]](self.links_s[ipt])
                    )

                elif rotType == 8:
                    varname = self.axis[self.curveIDNames[ipt]]["rotAxisVar"]
                    slVar = self.DV_listSectionLocal[varname]
                    attachedPoint = self.ptAttachInd[ipt]
                    W = slVar.sectionTransform[slVar.sectionLink[attachedPoint]][:, 2]
                    D = geo_utils.rotVbyW(D, W, np.pi / 180 * self.rot_theta[self.curveIDNames[ipt]](self.links_s[ipt]))

                D[0] *= scale_x
                D[1] *= scale_y
                D[2] *= scale_z

                if isComplex:
                    new_pts[ipt] = base_pt + D * scale
                else:
                    new_pts[ipt] = np.real(base_pt + D * scale)

        The core update rountine. pulled out here to eliminate duplication between update and
        update_deriv.
        
The core update rountine. pulled out here to eliminate duplication between update and
update_deriv.
The core update rountine . pulled out here to eliminate duplication between update and update_deriv .
def updateCalculations(self, new_pts, isComplex, config):
        if self.isChild:
            self.links_x = self.links_x.astype("D")
            for ipt in range(self.nPtAttach):
                base_pt = self.refAxis.curves[self.curveIDs[ipt]](self.links_s[ipt])
                self.links_x[ipt] = self.FFD.coef[self.ptAttachInd[ipt], :] - base_pt
        for key in self.DV_listGlobal:
            self.DV_listGlobal[key](self, config)
        self.refAxis.coef = self.coef.copy()
        self.refAxis._updateCurveCoef()
        for ipt in range(self.nPtAttach):
            base_pt = self.refAxis.curves[self.curveIDs[ipt]](self.links_s[ipt])
            ang = self.axis[self.curveIDNames[ipt]]["rot0ang"]
            ax_dir = self.axis[self.curveIDNames[ipt]]["rot0axis"]
            scale = self.scale[self.curveIDNames[ipt]](self.links_s[ipt])
            scale_x = self.scale_x[self.curveIDNames[ipt]](self.links_s[ipt])
            scale_y = self.scale_y[self.curveIDNames[ipt]](self.links_s[ipt])
            scale_z = self.scale_z[self.curveIDNames[ipt]](self.links_s[ipt])
            rotType = self.axis[self.curveIDNames[ipt]]["rotType"]
            if rotType == 0:
                bp_ = np.copy(base_pt)  
                if isinstance(ang, (float, int)):  
                    ang *= np.pi / 180  
                    base_pt = geo_utils.rotVbyW(bp_, ax_dir, ang)
                deriv = self.refAxis.curves[self.curveIDs[ipt]].getDerivative(self.links_s[ipt])
                deriv /= geo_utils.euclideanNorm(deriv)  
                new_vec = -np.cross(deriv, self.links_n[ipt])
                if isComplex:
                    new_pts[ipt] = bp_ + new_vec * scale  
                else:
                    new_pts[ipt] = np.real(bp_ + new_vec * scale)
                if isinstance(ang, (float, int)):
                    nv_ = np.copy(new_vec)
                    new_vec = geo_utils.rotVbyW(nv_, ax_dir, ang)
                new_vec[0] *= scale_x
                new_vec[1] *= scale_y
                new_vec[2] *= scale_z
                if isinstance(ang, (float, int)):
                    nv_rot = np.copy(new_vec)  
                    new_vec = geo_utils.rotVbyW(nv_rot, ax_dir, -ang)
                new_vec = geo_utils.rotVbyW(
                    new_vec, deriv, self.rot_theta[self.curveIDNames[ipt]](self.links_s[ipt]) * np.pi / 180
                )
                if isComplex:
                    new_pts[ipt] = bp_ + new_vec
                else:
                    new_pts[ipt] = np.real(bp_ + new_vec)
            else:
                rotX = geo_utils.rotxM(self.rot_x[self.curveIDNames[ipt]](self.links_s[ipt]))
                rotY = geo_utils.rotyM(self.rot_y[self.curveIDNames[ipt]](self.links_s[ipt]))
                rotZ = geo_utils.rotzM(self.rot_z[self.curveIDNames[ipt]](self.links_s[ipt]))
                D = self.links_x[ipt]
                rotM = self._getRotMatrix(rotX, rotY, rotZ, rotType)
                if self.coefRotM is not None:
                    attachedPoint = self.ptAttachInd[ipt]
                    if isComplex:
                        self.coefRotM[attachedPoint] = rotM
                    else:
                        self.coefRotM[attachedPoint] = np.real(rotM)
                D = np.dot(rotM, D)
                if rotType == 7:
                    deriv = self.refAxis.curves[self.curveIDs[ipt]].getDerivative(self.links_s[ipt])
                    deriv /= geo_utils.euclideanNorm(deriv)  
                    D = geo_utils.rotVbyW(
                        D, deriv, np.pi / 180 * self.rot_theta[self.curveIDNames[ipt]](self.links_s[ipt])
                    )
                elif rotType == 8:
                    varname = self.axis[self.curveIDNames[ipt]]["rotAxisVar"]
                    slVar = self.DV_listSectionLocal[varname]
                    attachedPoint = self.ptAttachInd[ipt]
                    W = slVar.sectionTransform[slVar.sectionLink[attachedPoint]][:, 2]
                    D = geo_utils.rotVbyW(D, W, np.pi / 180 * self.rot_theta[self.curveIDNames[ipt]](self.links_s[ipt]))
                D[0] *= scale_x
                D[1] *= scale_y
                D[2] *= scale_z
                if isComplex:
                    new_pts[ipt] = base_pt + D * scale
                else:
                    new_pts[ipt] = np.real(base_pt + D * scale)
def updateCalculations ( self , new_pts , isComplex , config ) : if self . isChild : self . links_x = self . links_x . astype ( "D" ) for ipt in range ( self . nPtAttach ) : base_pt = self . refAxis . curves [ self . curveIDs [ ipt ] ] ( self . links_s [ ipt ] ) self . links_x [ ipt ] = self . FFD . coef [ self . ptAttachInd [ ipt ] , : ] - base_pt for key in self . DV_listGlobal : self . DV_listGlobal [ key ] ( self , config ) self . refAxis . coef = self . coef . copy ( ) self . refAxis . _updateCurveCoef ( ) for ipt in range ( self . nPtAttach ) : base_pt = self . refAxis . curves [ self . curveIDs [ ipt ] ] ( self . links_s [ ipt ] ) ang = self . axis [ self . curveIDNames [ ipt ] ] [ "rot0ang" ] ax_dir = self . axis [ self . curveIDNames [ ipt ] ] [ "rot0axis" ] scale = self . scale [ self . curveIDNames [ ipt ] ] ( self . links_s [ ipt ] ) scale_x = self . scale_x [ self . curveIDNames [ ipt ] ] ( self . links_s [ ipt ] ) scale_y = self . scale_y [ self . curveIDNames [ ipt ] ] ( self . links_s [ ipt ] ) scale_z = self . scale_z [ self . curveIDNames [ ipt ] ] ( self . links_s [ ipt ] ) rotType = self . axis [ self . curveIDNames [ ipt ] ] [ "rotType" ] if rotType == 0 : bp_ = np . copy ( base_pt ) if isinstance ( ang , ( float , int ) ) : ang *= np . pi / 180 base_pt = geo_utils . rotVbyW ( bp_ , ax_dir , ang ) deriv = self . refAxis . curves [ self . curveIDs [ ipt ] ] . getDerivative ( self . links_s [ ipt ] ) deriv /= geo_utils . euclideanNorm ( deriv ) new_vec = - np . cross ( deriv , self . links_n [ ipt ] ) if isComplex : new_pts [ ipt ] = bp_ + new_vec * scale else : new_pts [ ipt ] = np . real ( bp_ + new_vec * scale ) if isinstance ( ang , ( float , int ) ) : nv_ = np . copy ( new_vec ) new_vec = geo_utils . rotVbyW ( nv_ , ax_dir , ang ) new_vec [ 0 ] *= scale_x new_vec [ 1 ] *= scale_y new_vec [ 2 ] *= scale_z if isinstance ( ang , ( float , int ) ) : nv_rot = np . copy ( new_vec ) new_vec = geo_utils . rotVbyW ( nv_rot , ax_dir , - ang ) new_vec = geo_utils . rotVbyW ( new_vec , deriv , self . rot_theta [ self . curveIDNames [ ipt ] ] ( self . links_s [ ipt ] ) * np . pi / 180 ) if isComplex : new_pts [ ipt ] = bp_ + new_vec else : new_pts [ ipt ] = np . real ( bp_ + new_vec ) else : rotX = geo_utils . rotxM ( self . rot_x [ self . curveIDNames [ ipt ] ] ( self . links_s [ ipt ] ) ) rotY = geo_utils . rotyM ( self . rot_y [ self . curveIDNames [ ipt ] ] ( self . links_s [ ipt ] ) ) rotZ = geo_utils . rotzM ( self . rot_z [ self . curveIDNames [ ipt ] ] ( self . links_s [ ipt ] ) ) D = self . links_x [ ipt ] rotM = self . _getRotMatrix ( rotX , rotY , rotZ , rotType ) if self . coefRotM is not None : attachedPoint = self . ptAttachInd [ ipt ] if isComplex : self . coefRotM [ attachedPoint ] = rotM else : self . coefRotM [ attachedPoint ] = np . real ( rotM ) D = np . dot ( rotM , D ) if rotType == 7 : deriv = self . refAxis . curves [ self . curveIDs [ ipt ] ] . getDerivative ( self . links_s [ ipt ] ) deriv /= geo_utils . euclideanNorm ( deriv ) D = geo_utils . rotVbyW ( D , deriv , np . pi / 180 * self . rot_theta [ self . curveIDNames [ ipt ] ] ( self . links_s [ ipt ] ) ) elif rotType == 8 : varname = self . axis [ self . curveIDNames [ ipt ] ] [ "rotAxisVar" ] slVar = self . DV_listSectionLocal [ varname ] attachedPoint = self . ptAttachInd [ ipt ] W = slVar . sectionTransform [ slVar . sectionLink [ attachedPoint ] ] [ : , 2 ] D = geo_utils . rotVbyW ( D , W , np . pi / 180 * self . rot_theta [ self . curveIDNames [ ipt ] ] ( self . links_s [ ipt ] ) ) D [ 0 ] *= scale_x D [ 1 ] *= scale_y D [ 2 ] *= scale_z if isComplex : new_pts [ ipt ] = base_pt + D * scale else : new_pts [ ipt ] = np . real ( base_pt + D * scale )
The core update rountine.
The core update rountine .
"""
        The core update rountine. pulled out here to eliminate duplication between update and
        update_deriv.
        """ # If this is a child, update the links between the ref axis and the # coefficients on the nested FFD now that the nested FFD has been # moved. # **Important**: this expects the FFD coef to be clean on this level, # meaning that the only changes to FFD.coef can be coming from # higher levels. # just use complex dtype here. we will convert to real in the end # Run Global Design Vars # update the reference axis now that the new global vars have been run # Variables for rotType = 0 rotation + scaling # copy of original pointset - will not be rotated # rotation active only if a non-default value is provided # conv to [rad] # Rotating the FFD according to inputs # The FFD points should now be aligned with the main system of reference # Normalize # using "unrotated" bp_ vector # Rotating to be aligned with main sys ref # Apply scaling # Rotating back the scaled pointset to its original position # nv_rot is scaled and rotated # if necessary, assign rotation matrix for each ffd coef # only apply the theta rotations in certain cases # Normalize
self
new_pts
isComplex
config