def read_txt(self, filePath, overwrite=True, afType=1): """ reads in airfoil coordinates file in text format. Parameters ---------- filePath : path absolute path of text file to read overwrite : bool if True then overwrites coordinates in self.coord otherwise returns coordinates as numpy array. afType : integer type of airfoil file. 1 or 2 """ if afType == 1: out = self.read_txt_1(filePath) if overwrite: self.coord = out[0] self.upPts, self.loPts = geom.separate_coordinates(self.coord) self.name = out[1] else: return out[0] elif afType == 2: out = self.read_txt_2(filePath) if overwrite: self.upPts = out[0] self.loPts = out[1] self.join_coordinates() self.name = out[2] else: return geom.join_coordinates(out[0], out[1])
def redim(self, numPts=121, overwrite=False, updCurves=True): """ Redimension and redistribution of airfoil points using cosine function. More points are located at leading and trailing edge. Parameters ---------- numPts : integer number of points for target airfoil. If number of points is same as source airfoil, points will be redistributed to make smooth surface overwrite : bool If True then self.coord, self.upPts and self.loPts will be overwritten, otherwise will return array of redimensioned points in format of self.coord """ def cos_curve(x): phi = x * pi return (cos(phi) + 1.0) / 2.0 if (numPts % 2) == 1: numPts = int(numPts) / 2 + 1 tUp = linspace(0.0, 1.0, numPts) tLo = tUp else: numPts = int(numPts) / 2 + 1 tUp = linspace(0.0, 1.0, numPts) tLo = linspace(0.0, 1.0, numPts - 1) tUp = array([cos_curve(t) for t in tUp]) tLo = array([cos_curve(t) for t in tLo]) if updCurves: self.create_splines() xUp, yUp = self.upCurve(tUp) xLo, yLo = self.loCurve(tLo) upPts = transpose(vstack([xUp, yUp])) loPts = transpose(vstack([xLo, yLo])) coord = geom.join_coordinates(upPts, loPts) if overwrite: self.coord = coord self.upPts = upPts self.loPts = loPts else: return coord
def redim(self,nPts,overwrite=True,distribution='sin'): """ Redimension and redistribution of airfoil points using cosine function. More points are located at leading and trailing edge. Parameters ---------- numPts : integer number of points for target airfoil. If number of points is same as source airfoil, points will be redistributed to make smooth surface overwrite : bool If True then self.pts, self.upPts and self.loPts will be overwritten, otherwise will return array of redimensioned points in format of self.pts """ if nPts%2==0: nPts1 = nPts/2 nPts2 = nPts/2+1 else: nPts1 = (nPts+1)/2 nPts2 = nPts1 #nPts *= 0.5 t1 = self._get_point_distribution(nPts1,distribution) t2 = self._get_point_distribution(nPts2,distribution) self._create_splines() xUp, yUp = self._curveUp(t1) xLo, yLo = self._curveLo(t2) upPts = np.transpose(np.vstack([xUp,yUp])) loPts = np.transpose(np.vstack([xLo,yLo])) coord = geom.join_coordinates(upPts,loPts) if overwrite: self.pts = coord self.ptsUp = upPts self.ptsLo = loPts else: return coord
def join_coordinates(self): self.coord = geom.join_coordinates(self.upPts, self.loPts)
def _join_coordinates(self): self.pts = geom.join_coordinates(self.ptsUp, self.ptsLo)