def __init__(self, name, shape, chord=1., local_pitch=0., pivot_point=[0., 0.]): # Storing body Parameters self.name = name # name self.chord = chord # chord length self.local_pitch = local_pitch # pitch angle self.pivot_point = np.array([pivot_point]).transpose() # origin of body w.r.t global geometry # Generating coordintes if shape[0] is 'cylinder': self.geometry_normalized = generateCoordinates.cylinder2D(shape[1]) elif shape[0] is 'block': # generate block coordinates self.geometry_normalized = generateCoordinates.block2D(shape[1]) else: # body is airfoil; # extract data from file containing normalized coordinates # coordinates are given anti-clockwise self.geometry_normalized = getCoordinates(filename = shape[0], clockwise = shape[1]) # Storing body geometry and its parameters # non-normalized geometry (with pitch and correct center) self.geometry = body2global((self.geometry_normalized - self.pivot_point)*self.chord, self.local_pitch) # Number of coordinate point self.noPoints = np.shape(self.geometry)[1]
def __init__(self,*args): # Extracting initial data # Initializing the lists of variables self.name = [] self.length_geometry = [] self.length_panel = [] # Scanning through the 'args' and getting the data for data in args: # Extracting the global parameters of the body # Extracting initial data from the bodies self.name.append(data['body'].name) # body names self.length_geometry.append(data['body'].noPoints) # number of geometry points self.length_panel.append(data['body'].noPoints-1) # number of panel points # Initializing the arrays for storing all the data [reduce computational load] self.chord = np.zeros(len(args)) # 1-D array of chords self.local_pitch = np.zeros(len(args)) self.global_pitch= np.zeros(len(args)) self.location = np.zeros((2,len(args))) self.geometry = np.zeros((2,sum(self.length_geometry))) # x,y coordinates in row 0 and 1 self.panelStart = np.zeros((2,sum(self.length_panel))) self.panelEnd = np.zeros((2,sum(self.length_panel))) # Storing all the data # Pointer parameters i = 0 start_geometry = 0 start_panel = 0 # Looping through the available data for data in args: # Calculating the shape of 'sub array'. Finding the end point end_geometry = start_geometry + self.length_geometry[i] end_panel = start_panel + self.length_panel[i] # Storing all the data together into an array self.chord[i] = data['body'].chord self.local_pitch[i] = data['body'].local_pitch self.global_pitch[i]= data['global_pitch'] self.location[:,i] = np.array([data['location']]) # Transforming the points and vectors to global coordinates. self.geometry[:,start_geometry:end_geometry] = body2global(data['body'].geometry, self.global_pitch[i], self.location[:,i]) self.panelStart[:,start_panel:end_panel] = self.geometry[:,start_geometry:(end_geometry-1)] # starting points self.panelEnd[:,start_panel:end_panel] = self.geometry[:,(1+start_geometry):end_geometry] # Preparing for the next iteration start_geometry = end_geometry start_panel = end_panel i+=1 self.normal = normalVector(self.panelStart, self.panelEnd) self.tangent = tangentVector(self.panelStart, self.panelEnd) self.collocationPoint = (self.panelStart + self.panelEnd)/2 self.vortex_collocationPoint = collocationPoint(self.panelStart,self.panelEnd, -self.normal) # inside the body self.source_collocationPoint = collocationPoint(self.panelStart,self.panelEnd, self.normal) # inside the body