def pulsatile_cylinder_create_flow_files_generic(dstdir): # Write sinusodial flowrate print("Generating sinusodial volumetric flow waveform.") T = 0.2 Vbar = 135.0 radius = 2.0 # calculate FFT terms pts = [] os.mkdir(dstdir + '/flow-files') fp = open(dstdir + '/flow-files/inflow.flow', 'w+') fp.write("# Time (sec) Flow (cc/sec)\n") #fp.write("0 -1570.796327\n") #fp.write("0.2 -1570.796327\n") for i in range(0, 256): dt = T / 255.0 t = i * dt Vmean = Vbar * (1.0 + math.sin(2 * math.pi * t / T)) area = math.pi * radius * radius pts.append([t, -Vmean * area]) fp.write("%.10f %.10f\n" % (t, -Vmean * area)) fp.close() print("Calculate analytic profile for outlet. (not done!!)") terms = Math.FFT(pts, 2, 256) return terms
viscosity = 0.004 density = 0.00106 T = 0.2 Vbar = 135 radius = 2.0 omega = 2.0*math.pi/T pts = [] for i in range(0,256): dt = T/255.0 t = float(i)*dt Vmean = Vbar*(1.0+math.sin(2*math.pi*t/T)) area = math.pi*radius*radius pts.append([t, -Vmean*area]) terms = Math.FFT(pts, 2,256) try: Repository.Delete('outflow') except: pass import os import stat os.chmod(fullrundir+'/mesh-complete/mesh-surfaces', 0o777) Repository.ReadXMLPolyData('outflow',fullrundir+'/mesh-complete/mesh-surfaces/outlet.vtp') numPts = Geom.NumPts('outflow') outflowObj = Repository.ExportToVtk('outflow') outflowScalars = outflowObj.GetPointData().GetScalars() print ("Reading simulation results: " + resfn) resReader = vtk.vtkXMLUnstructuredGridReader()