import time import csv import os, sys def AnimateViews(v1,v2,steps): RV = GetView3D() for i in range(steps): t= float( i+1 ) / float(steps) x = v1.viewNormal[0] * (1.0 - t) + v2.viewNormal[0] * t y = v1.viewNormal[1] * (1.0 - t) + v2.viewNormal[1] * t z = v1.viewNormal[2] * (1.0 - t) + v2.viewNormal[2] * t RV.viewNormal = (x, y, z) SetView3D(RV) def ZoomRendering(v, array1): for n in array1: v.parallelScale = n SetView3D(v) return(v) file_data="/plx/usermisc/tryvis01/multi_ucd3d.silo" variable = "vec_magnitude" path_file_out="/plx/usermisc/tryvis01/benchmark_visit" name_file_out="bench_out.csv" list_time=['np'] OpenComputeEngine() # OPEN # print "Opening, Reading and Outline Rendering of the file: " print file_data start=time.time() OpenDatabase(file_data) AddPlot("Volume", variable) volumeAtt = VolumeAttributes() volumeAtt.rendererType = volumeAtt.Texture3D SetPlotOptions(volumeAtt) v = GetView3D() v.focus = (0,2.5,10) v.viewAngle = 30 v.viewNormal = (0, 0, 1) v.parallelScale = 8.5 v.viewUp = (0, 1, 0) v.nearPlane = -1119.61 v.farPlane = 2309.195 v.imagePan = (0, 0) v.imageZoom = 0.5 v.perspective = 1 v.eyeAngle = 2 v.centerOfRotationSet = 0 v.centerOfRotation = (0, 2.5, 10) v.axis3DScaleFlag = 0 v.axis3DScales = (1, 1, 1) v.shear = (0, 0, 1) SetView3D(v) DrawPlots() ttcompute= time.time()-start list_time.append(str('%.4f' %ttcompute)) print "wall time of reading and GPU-volume rendering of the file:",ttcompute # ZOOM and ANIMATE GPU-based # print "Zoom in of the GPU-Volume Rendering:" array1=[8, 7.5, 7, 6.5, 6, 5.5, 5, 4.5, 4, 3.5, 3] start=time.time() ZoomRendering(v, array1) ttcompute=time.time()-start list_time.append(str('%.4f' %ttcompute)) print "Wall time GPU-Volume Rendering + Zoom= ",ttcompute print "GPU-Volume Rendering animate" v1 = GetView3D() v1.viewNormal = (-0.5, 0.3, 1) v1.parallelScale = 7 SetView3D(v1) v2 = GetView3D() v2.viewNormal = (1, -0.3, -0.5) start=time.time() AnimateViews(v1, v2, 20) AnimateViews(v2, v1, 20) ttcompute=time.time()-start list_time.append(str('%.4f' %ttcompute)) print "Wall time GPU-Volume Rendering animate",ttcompute # ZOOM and ANIMATE SOFTWARE-based # print "Zoom in of the Volume Rendering, no GPU:" volumeAtt = VolumeAttributes() volumeAtt.samplesPerRay = 500 volumeAtt.rendererType = volumeAtt.RayCasting SetPlotOptions(volumeAtt) v = GetView3D() v.viewNormal = (0, 0, 1) v.parallelScale = 8.5 SetView3D(v) array1=[8, 7.5, 7, 6.5, 6, 5.5, 5, 4.5, 4, 3.5, 3] start=time.time() ZoomRendering(v, array1) ttcompute=time.time()-start list_time.append(str('%.4f' %ttcompute)) print "Wall time Volume Rendering + Zoom no GPU= ",ttcompute print "Volume Rendering animate, no GPU" v1 = GetView3D() v1.viewNormal = (-0.5, 0.3, 1) v1.parallelScale = 7 SetView3D(v1) v2 = GetView3D() v2.viewNormal = (1, -0.3, -0.5) start=time.time() AnimateViews(v1, v2, 20) AnimateViews(v2, v1, 20) ttcompute=time.time()-start list_time.append(str('%.4f' %ttcompute)) print "Wall time Volume Rendering animate, no GPU",ttcompute DeleteAllPlots() # CONTOUR # print "Contour" start = time.time() AddPlot("Contour", variable) print "Rotazione del Contour" v1 = GetView3D() v1.viewNormal = (-0.5, 0.3, 1) v1.parallelScale = 7 SetView3D(v1) DrawPlots() v2 = GetView3D() v2.viewNormal = (1, -0.3, -0.5) AnimateViews(v1, v2, 20) AnimateViews(v2, v1, 20) ttcompute=time.time()-start list_time.append(str('%.4f' %ttcompute)) print 'Contour + Animate wall time',ttcompute print "Zoom in of the Contour Rendering" v = GetView3D() v.viewNormal = (0, 0, 1) v.parallelScale = 8.5 SetView3D(v) start=time.time() ZoomRendering(v, array1) ttcompute=time.time()-start print " Contour Zoom wall time= ",ttcompute list_time.append(str('%.4f' %ttcompute)) DeleteAllPlots() CloseComputeEngine() CloseDatabase(file_data) # Append list_time to csv file list_path=os.listdir(path_file_out) test=[elem for elem in list_path if elem==name_file_out] file_output=path_file_out+'/'+name_file_out print 'file_output=',file_output print 'test=',test,'len(test)=',len(test) if len(test)==0: csvfile = open(file_output,"w") writer=csv.writer(csvfile) intestazione=['Procs','Read','Zoom_VR_GPU','Animate_VR_GPU', 'Zoom_VR_noGPU', 'Animate_VR_noGPU','Animate_Contour','Zoom_Contour'] writer.writerow(intestazione) else: csvfile = open(file_output,"a") writer=csv.writer(csvfile) writer.writerow(list_time) csvfile.close() print 'END'