Example #1
0
 def initResamplingMatrices(self):
     """
     Pre-compute resampling matrices that go from N points to 2N points and vice versa.
     """
     self._MatfromNto2N = cf.ResamplingMatrix(2 * self._N, self._N,
                                              chebGridType, chebGridType)
     self._MatfromNtoDirectN = cf.ResamplingMatrix(self._nptsDirect,
                                                   self._N, chebGridType,
                                                   chebGridType)
     self._MatfromDirectNtoN = cf.ResamplingMatrix(self._N,
                                                   self._nptsDirect,
                                                   chebGridType,
                                                   chebGridType)
     self._Matfrom2NtoN = cf.ResamplingMatrix(self._N, 2 * self._N,
                                              chebGridType, chebGridType)
     self._stackMatfromNto2N = np.zeros((6 * self._N, 3 * self._N))
     self._stackMatfrom2NtoN = np.zeros((3 * self._N, 6 * self._N))
     for iD in range(3):
         self._stackMatfromNto2N[iD::3, iD::3] = self._MatfromNto2N
         self._stackMatfrom2NtoN[iD::3, iD::3] = self._Matfrom2NtoN
     W2N = np.diag(np.repeat(self._w2N, 3))
     UTWU = np.dot(self._stackMatfromNto2N.T,
                   np.dot(W2N, self._stackMatfromNto2N))
     self._LeastSquaresDownsampler = np.linalg.solve(
         UTWU, np.dot(self._stackMatfromNto2N.T, W2N))
     self._WeightedUpsamplingMat = np.dot(W2N, self._stackMatfromNto2N)
     self._UpsampledChebPolys = np.dot(self._MatfromNto2N,
                                       self._Lmat[:, :self._nPolys]).T
Example #2
0
 def initD4BC(self):
     """
     Compute the operator D_4^BC that is necessary when computing 
     the bending forces. The constant -E_bend is included in 
     this operator
     """
     DownsamplingMat = cf.ResamplingMatrix(self._N, self._N + numBCs,
                                           chebGridType, D4BCgridType)
     SecDMat_upgrid = cf.diffMat(2, [0, self._L], 2, self._N + numBCs,
                                 D4BCgridType, D4BCgridType)
     ThirDMat_upgrid = cf.diffMat(3, [0, self._L], 2, self._N + numBCs,
                                  D4BCgridType, D4BCgridType)
     TotalBCMatrix = np.concatenate(
         (DownsamplingMat, SecDMat_upgrid, ThirDMat_upgrid))
     # This is the only place where you would modify the "free fiber" BCs
     RHS = np.concatenate((np.identity(self._N), np.zeros((4, self._N))))
     TildeConfigMatrix = np.linalg.solve(TotalBCMatrix, RHS)
     FourDMat_fromUptoDwn = cf.diffMat(4, [0, self._L], self._N,
                                       self._N + numBCs, chebGridType,
                                       D4BCgridType)
     OneD4BC = -self._Eb * np.dot(FourDMat_fromUptoDwn, TildeConfigMatrix)
     # Stack up OneD4BC three times since there are 3 coordinates
     self._D4BC = np.zeros((3 * self._N, 3 * self._N))
     for iD in range(3):
         self._D4BC[iD::3, iD::3] = OneD4BC
Example #3
0
 def resample(self, Xarg, Nrs, typetarg=chebGridType):
     """
     Resample the fiber at Nrs Chebyshev nodes of type type
     Inputs: Xarg = a self._N x 3 vector of the fiber points,
     Nrs = number of points where the resampling is desired. typetarg = type
     of Chebyshev points (defaults to 1)
     Outputs: the resampled locations as an Nrs x 3 vector of points. 
     """
     RMatrix = cf.ResamplingMatrix(Nrs, self._N, typetarg, chebGridType)
     Xrs = np.dot(RMatrix, Xarg)
     return Xrs
Example #4
0
 def initSpecialQuadMatrices(self):
     """
     Initialize matrices that are necessary for special quadrature / resampling.
     """
     self._MatfromNtoUpsamp = cf.ResamplingMatrix(self._nptsUpsample,
                                                  self._N, chebGridType,
                                                  chebGridType)
     self._MatfromNto2panUp = cf.ResamplingMatrix(self._nptsUpsample,self._N,chebGridType,chebGridType,\
                 nPantarg=2)
     self._MatfromNtoUniform = cf.ResamplingMatrix(self._nptsUniform,
                                                   self._N, 'u',
                                                   chebGridType)
     self._UpsampledCoefficientsMatrix = cf.CoeffstoValuesMatrix(
         self._nptsUpsample, self._nptsUpsample, chebGridType)
     self._UpsampCoeffLU = lu_factor(self._UpsampledCoefficientsMatrix)
     # Initialize LU factorization of vandermonde matrix for special quadrature
     self._specQuadNodes = cf.chebPts(self._nptsUpsample, [-1, 1],
                                      chebGridType)
     self._upsampledWeights = cf.chebWts(self._nptsUpsample, [0, self._L],
                                         chebGridType)
     self._NupsampLUpiv = lu_factor(
         np.vander(self._specQuadNodes, increasing=True).T)
Example #5
0
 def get2PanelUpsamplingMatrix(self):
     return cf.ResamplingMatrix(self._N,
                                self._N,
                                chebGridType,
                                chebGridType,
                                nPantarg=2)