def __init__(self, testname, bndno, dt): print '\n***************************** Initializing Pfem *****************************' self.testname = testname # string (name of the module of the fluid model) self.bndno = bndno # phygroup# of the f/s interface # internal vars self.vnods = [] # dict of interface nodes / prescribed velocities self.t1 = 0.0 # last reference time self.t2 = 0.0 # last calculated time # loads the python module #load(self.testname) # use toolbox.utilities exec("import %s" % self.testname) exec("module = %s" % self.testname) # link to Pfem object # create an instance of Pfem self.pfem = module.getPfem() self.realTimeExtractorsList = module.getRealTimeExtractorsList( self.pfem) # retrieve the f/s boundary and the related nodes gr = self.pfem.w.Group(self.pfem.msh, bndno) # builds a list (dict) of interface nodes nods = {} for e in gr.tag.elems: for n in e.nodes: no = n.no nods[no] = n self.vnods = list(nods.values()) self.nNodes = len(self.vnods) self.nHaloNode = 0 # numbers of nodes at the f/s interface (halo) self.nPhysicalNodes = self.nNodes - self.nHaloNode # numbers of nodes at the f/s interface (physical) # Pfem scheme initialization self.V = self.pfem.w.DoubleVector() self.V0 = self.pfem.w.DoubleVector() self.u = self.pfem.w.DoubleVector() self.v = self.pfem.w.DoubleVector() self.p = self.pfem.w.DoubleVector() self.velocity = self.pfem.w.DoubleVector() self.pfem.scheme.t = 0. self.pfem.scheme.dt = dt self.pfem.scheme.init(self.V, self.V0, self.u, self.v, self.p, self.velocity) self.runOK = True FluidSolver.__init__(self) self.displ_x_Nm1 = np.zeros((self.nPhysicalNodes)) self.displ_y_Nm1 = np.zeros((self.nPhysicalNodes)) self.displ_z_Nm1 = np.zeros((self.nPhysicalNodes))
def __init__(self, config): # You are free to add any arguments here """ Des. """ print '\n***************************** Initializing Example *****************************' #self.nNodes = # number of nodes (physical + ghost) at the f/s boundary #self.nHaloNode = # number of ghost nodes at the f/s boundary #self.nPhysicalNodes = # number of physical nodes at the f/s boundary FluidSolver.__init__(self) self.coreSolver = fluidWrapper.solverDriver(config) self.initRealTimeData()
def __init__(self, _module, _nthreads): # load the python module and initialize the solver module = __import__(_module) floP = module.getParams() self.__initFlow(floP, _nthreads) # count fsi nodes and get their positions self.nNodes = self.boundary.nodes.size() self.nHaloNode = 0 self.nPhysicalNodes = self.nNodes - self.nHaloNode self.nodalInitPosX, self.nodalInitPosY, self.nodalInitPosZ = self.getNodalInitialPositions() # init save frequency (fsi) if 'saveFreq' in floP: self.saveFreq = floP['saveFreq'] else: self.saveFreq = sys.maxsize # generic init FluidSolver.__init__(self)
def update(self): """ Des. """ FluidSolver.update(self)
def __init__(self, confFile, nDim, computationType, nodalLoadsType, have_MPI, MPIComm=None): """ Initialize the SU2 solver and all the required interface variables. """ # --- Instantiate the single zone driver of SU2 --- # # @todo [Adrien Crovato ]Change CFluidDriver constructor # as of SU2-6.1.0, a new way of handling periodic boundary conditon has been implemented # Consequently CDriver(config, nZone, nDim, MPIComm) changed to CFluidDriver(config, nZone, nDim, val_periodic, MPIComm) # Since periodic BC are not used yet in CUPyDO, I just adapted the constructor. This will have to be changed... try: self.SU2 = pysu2.CFluidDriver(confFile, 1, nDim, False, MPIComm) except TypeError as exception: print('A TypeError occured in pysu2.CSingleZoneDriver : ', exception) if have_MPI == True: print( 'ERROR : You are trying to initialize MPI with a serial build of the wrapper. Please, remove the --parallel option that is incompatible with a serial build.' ) else: print( 'ERROR : You are trying to launch a computation without initializing MPI but the wrapper has been built in parallel. Please add the --parallel option in order to initialize MPI for the wrapper.' ) allMovingMarkersTags = self.SU2.GetAllMovingMarkersTag( ) # list containing the tags of all moving markers allCHTMarkersTags = self.SU2.GetAllCHTMarkersTag() allMarkersID = self.SU2.GetAllBoundaryMarkers( ) # dic : allMarkersID['marker_tag'] = marker_ID self.fluidInterfaceID = None # identification of the f/s boundary, currently limited to one boundary, by default the first tag in allMovingMarkersTags if not allMovingMarkersTags and not allCHTMarkersTags: #raise Exception('No interface for FSI was defined.') self.fluidInterfaceID = None elif allMovingMarkersTags and not allCHTMarkersTags: if allMovingMarkersTags[0] in allMarkersID.keys(): self.fluidInterfaceID = allMarkersID[allMovingMarkersTags[0]] elif not allMovingMarkersTags and allCHTMarkersTags: if allCHTMarkersTags[0] in allMarkersID.keys(): self.fluidInterfaceID = allMarkersID[allCHTMarkersTags[0]] elif allMovingMarkersTags and allCHTMarkersTags: if allMovingMarkersTags[0] == allCHTMarkersTags[0]: if allMovingMarkersTags[0] in allMarkersID.keys(): self.fluidInterfaceID = allMarkersID[ allMovingMarkersTags[0]] else: raise Exception( "Moving and CHT markers have to be the same!\n") self.computationType = computationType # computation type : steady (default) or unsteady self.nodalLoadsType = nodalLoadsType # nodal loads type to extract : force (in N, default) or pressure (in Pa) # --- Calculate the number of nodes (on each partition) --- # self.nNodes = 0 self.nHaloNode = 0 self.nPhysicalNodes = 0 if self.fluidInterfaceID != None: self.nNodes = self.SU2.GetNumberVertices( self.fluidInterfaceID ) # numbers of nodes at the f/s interface (halo+physical) self.nHaloNode = self.SU2.GetNumberHaloVertices( self.fluidInterfaceID ) # numbers of nodes at the f/s interface (halo) self.nPhysicalNodes = self.nNodes - self.nHaloNode # numbers of nodes at the f/s interface (physical) self.nodalInitialPos_X = np.zeros( (self.nPhysicalNodes)) # initial position of the f/s interface self.nodalInitialPos_Y = np.zeros((self.nPhysicalNodes)) self.nodalInitialPos_Z = np.zeros((self.nPhysicalNodes)) self.haloNodesPositionsInit = {} FluidSolver.__init__(self) # --- Initialize the interface position and the nodal loads --- # PhysicalIndex = 0 for iVertex in range(self.nNodes): posX = self.SU2.GetVertexCoordX(self.fluidInterfaceID, iVertex) posY = self.SU2.GetVertexCoordY(self.fluidInterfaceID, iVertex) posZ = self.SU2.GetVertexCoordZ(self.fluidInterfaceID, iVertex) if self.SU2.IsAHaloNode(self.fluidInterfaceID, iVertex): GlobalIndex = self.SU2.GetVertexGlobalIndex( self.fluidInterfaceID, iVertex) self.haloNodeList[GlobalIndex] = iVertex self.haloNodesPositionsInit[GlobalIndex] = (posX, posY, posZ) else: self.SU2.ComputeVertexForces(self.fluidInterfaceID, iVertex) Fx = self.SU2.GetVertexForceX(self.fluidInterfaceID, iVertex) Fy = self.SU2.GetVertexForceY(self.fluidInterfaceID, iVertex) Fz = self.SU2.GetVertexForceZ(self.fluidInterfaceID, iVertex) Temp = self.SU2.GetVertexTemperature(self.fluidInterfaceID, iVertex) self.nodalInitialPos_X[PhysicalIndex] = posX self.nodalInitialPos_Y[PhysicalIndex] = posY self.nodalInitialPos_Z[PhysicalIndex] = posZ self.nodalLoad_X[PhysicalIndex] = Fx self.nodalLoad_Y[PhysicalIndex] = Fy self.nodalLoad_Z[PhysicalIndex] = Fz self.nodalTemperature[PhysicalIndex] = Temp PhysicalIndex += 1 self.initRealTimeData()
def __init__(self, _module): print "\n***************************** Initializing VLM *****************************" module = __import__(_module) pars = module.getParams() if not os.path.exists("models"): os.mkdir("models") # Needs to exist to write airfoil data w = inputs.VLMWing(pars["Airfoil"], pars["Span"], pars["Taper"], pars["SweepLE"], pars["Dihedral"], pars["Twist"], pars["RootChord"], pars["Offset"]) w.write_geofile(pars["Geofile"]) w.chordwise_panels = pars["ChordwisePanels"] w.spanwise_panels = pars["SpanwisePanels"] w.geometry_file = pars["Geofile"] # Initialise empty VTail and HTail v_airfoils = [] v_span = [] v_taper = [] v_sweep = [] v_dihedral = [] v_twist = [] v_root_chord = 0.5 v_offset = [0.0, 0.0] vtail = inputs.VLMVTail(v_airfoils, v_span, v_taper, v_sweep, v_dihedral, v_twist, v_root_chord, v_offset) h_airfoils = [] h_span = [] h_taper = [] h_sweep = [] h_dihedral = [] h_twist = [] h_root_chord = 0.5 h_offset = [0., 0.] htail = inputs.VLMHTail(h_airfoils, h_span, h_taper, h_sweep, h_dihedral, h_twist, h_root_chord, h_offset) properties = inputs.VLMProperties(w, htail, vtail) properties.u = pars["U_inf"] properties.rho = pars["Rho"] properties.AoA = pars["AoA"] properties.timesteps = pars["TimeSteps"] properties.denominator = pars["TimeDenominator"] properties.freewake = pars["FreeWake"] properties.infile = pars["Infile"] properties.write_infile() self.coreSolver = VLM_driver.VLMDriver(pars["Infile"]) self.isRun = False self.nNodes = self.coreSolver.data.wing.nvert+ \ self.coreSolver.data.flap.nvert+self.coreSolver.data.aileron.nvert # number of nodes (physical + ghost) at the f/s boundary self.nHaloNode = 0 # number of ghost nodes at the f/s boundary self.nPhysicalNodes = self.nNodes - self.nHaloNode # number of physical nodes at the f/s boundary FluidSolver.__init__(self) self.initRealTimeData()
def update(self, dt): FluidSolver.update(self, dt) self.coreSolver.update()