示例#1
0
def saveState( fileName='psi.h5' ):
  ensureDirectory( dataDir )
  psi_h = psi_d.get()
  print "Saving Data"
  outputName = dataDir + fileName
  dataFile = h5.File( outputName  ,'w')
  dataFile.create_dataset( "psi", data=psi_d.get(), compression='lzf')
  dataFile.close()
  print "Data Saved: {0}\n".format( outputName )
示例#2
0
def saveState():
  ensureDirectory( dataDir )
  psi_h = psi_d.get()
  print "Saving Data"
  np.savetxt(dataDir + "psi_re.dat", psi_h.real.reshape(nData) )
  np.savetxt(dataDir + "psi_im.dat", psi_h.imag.reshape(nData) )
  dataFile = h5.File( dataDir + 'psi.hdf5' ,'w')
  dataFile.create_dataset( "psi", data=psi_d.get(), compression='lzf')
  dataFile.close()
  print "Data Saved: {0}\n".format( dataDir )
示例#3
0
  occupancyOld = occupancy
  mainKernel(np.uint8(usingAnimation), np.int32(nParticles), np.int32(collisionsPerRun), np.int32(nCircles), circlesCaract_d, np.int32(nLines), linesCaract_d,
	    initialPosX_d, initialPosY_d, initialVelX_d, initialVelY_d, initialRegionX_d, initialRegionY_d,
	    outPosX_d, outPosY_d, times_d,
	    np.float32(deltaTime_anim), timesIdx_anim_d,
	    np.float32( deltaTime_radius ), timesIdx_rad_d, timesOccupancy_d, radiusAll_d,
	    np.uint8(savePos), np.int32(particlesForPlot), np.uint8(changeInitial),
	    np.intp(0),  grid=grid, block=block)
  launchCounter += 1
  #if runNumber%5==0  and plotting: plotData( runNumber )
print "\n\nFinished in : {0:.4f}  sec\n".format( float( start.time_till(end.record().synchronize())*1e-3 ) ) 

#Get the results
#Save data
dataDir = currentDirectory + "/data"
ensureDirectory( dataDir )
#data= np.array([ timesForRadius, radiusAll_d.get() ])
dataFileName = dataDir + "/n{0}_t{1:.0f}_{2}.hdf5".format(nParticles, float(maxTime), cudaP[0])
dataFile = h5.File(dataFileName,'w')
dataFile.create_dataset( "posParticles", data=np.array([initialPosX_d.get(), initialPosY_d.get() ]), compression='lzf')
dataFile.create_dataset( "velParticles", data=np.array([initialVelX_d.get(), initialVelY_d.get() ]), compression='lzf')
dataFile.create_dataset( "regParticles", data=np.array([initialRegionX_d.get(), initialRegionY_d.get() ]), compression='lzf')
dataFile.create_dataset( "timesForRadius", data=timesForRadius, compression='lzf')
dataFile.create_dataset( "avrRadius", data=radiusAll_d.get(), compression='lzf')
dataFile.close()
#np.savetxt( dataFile, data )
print "Data Saved: ", dataFileName, "\n"

if plotFinal:
  outPosX = np.zeros(nData + particlesForPlot)
  outPosY = np.zeros(nData + particlesForPlot)
示例#4
0
#Add Modules from other directories
currentDirectory = os.getcwd()
parentDirectory = currentDirectory[:currentDirectory.rfind("/")]
toolsDirectory = parentDirectory + "/tools"
volumeRenderDirectory = parentDirectory + "/volumeRender"
sys.path.extend( [toolsDirectory, volumeRenderDirectory] )
from cudaTools import *
from tools import ensureDirectory, printProgressTime
from mpiTools import *

cudaP = "double"
nPoints = 128
useDevice = None
usingAnimation = False
outDir = '/home_local/bruno/data/gravity/'
ensureDirectory( outDir )

for option in sys.argv:
  if option == "float": cudaP = "float"
  if option == "anim": usingAnimation = True
  if option == "mem": showKernelMemInfo = True
precision  = {"float":(np.float32, np.complex64), "double":(np.float64,np.complex128) }
cudaPre, cudaPreComplex = precision[cudaP]

#Initialize MPI
MPIcomm = MPI.COMM_WORLD
pId = MPIcomm.Get_rank()
nProcess = MPIcomm.Get_size()
name = MPI.Get_processor_name()

if pId == 0:
示例#5
0
######################################################################################
######################################################################################


#configure volumeRender functions  
if usingAnimation: 
  volumeRender.viewTranslation[2] = -2
  #volumeRender.keyboard = keyboard
  #volumeRender.specialKeys = specialKeyboardFunc
  volumeRender.stepFunc = stepFuntion
  #run volumeRender animation
  volumeRender.animate()

#Open outFile
snapsDir = dataDir + 'snapshots/'
ensureDirectory( snapsDir )
n = len( [ f for f in os.listdir( snapsDir ) if f.find(timeDirection)>0 ] )
snapsFileName = snapsDir + 'psi_{0}_{1}.h5'.format( timeDirection, n )
snapsFile = h5.File( snapsFileName, 'w')
  
print "\nnPoints: {0}x{1}x{2}".format(nWidth, nHeight, nWidth )
print 'Snapshots File: ', snapsFileName
print "Starting Real Dynamics: {0} timeUnits, dt: {1:1.2e} \n".format( endTime, dtReal )  

printCounter = 0
start, end = cuda.Event(), cuda.Event()
start.record()
for n in range( nSnapshots ):
  end.record().synchronize()
  printProgressTime( n, nSnapshots,  start.time_till(end)*1e-3 )
  saveSnapshot( n, snapsFile, simulationTime, psi_d.get() )