else: # nothing given print("read_parts error: Invalid commandline arguments.") print("Usage: ") print(" ./read_parts.py <./path/to/sim/output> <start_time>") print(" or") print(" ./read_parts.py <./path/to/sim/output>") sys.exit() # initialize the reader times = bbparts.init(data_dir) # visit all outputted time values for time in times: # open the CGNS file for this particular output time bbparts.open(time) # read the CGNS file t = bbparts.read_time() n = bbparts.read_nparts() (x, y, z) = bbparts.read_part_position() (u, v, w) = bbparts.read_part_velocity() print("time = ", time, "t =", t, "n =", n) print(u) sys.exit() # close the CGNS file bbparts.close()
nt = len(timeseries) # close this output bb.close() # overwrite number of time outputs to read (for testing) #nt = 300 #t_end = 3 #################################################################### # store particle position data at initial time t_init #################################################################### timeseries = bb.init(ensemble[0] + "/output")[int(timestart/DT_out):] bb.open(timeseries[0]) # using time step 0 for now (X_init, Y_init, Z_init) = bb.read_part_position() T_init = bb.read_time() np = len(X_init) # also store particle number bb.close() # create particle lists # last particle position X0 = numpy.zeros(np) Y0 = numpy.zeros(np) Z0 = numpy.zeros(np) # current particle position X = numpy.zeros(np) Y = numpy.zeros(np) Z = numpy.zeros(np) # current particle velocity U = numpy.zeros(np)
#!/usr/bin/env python # bluebottle_particle_reader python module example code import sys, getopt import numpy as np import bluebottle_particle_reader as bb # initialize the reader times = bb.init("/home/asiera/bluebottle/sim/output") # visit all outputted time values for time in times: # open the CGNS file for this particular output time bb.open(time) # read the CGNS file t = bb.read_time() (x,y,z) = bb.read_part_position() (u,v,w) = bb.read_part_velocity() print("t =", t) # close the CGNS file bb.close()
# Predefine simulation parameters a = 2.1 Lx = 42. Ly = 42. Lz = 126. r = 3.*a # kd-tree search radius #################################################### #### Initialize particle pairs using a k-d-tree #### #################################################### # Pull initial particle positions bbparts.open(times[0]) (x0, y0, z0) = bbparts.read_part_position() bbparts.close() # If we initialize over periodic boundaries, then flipping later for periodic # boundaries is difficult. We did it for tetrads, but for now, just ignore that. # Rescale data to ([0,Lx], [0, Ly], [0, Lz]) #boxsize = np.array([Lx,Ly,Lz,Lx,Ly,Lz]) #data = np.c_[x0.ravel() + 0.5*Lx, # y0.ravel() + 0.5*Ly, # z0.ravel() + 0.5*Lz] # Set up tree with particle positions data = np.c_[x0.ravel(), y0.ravel(), z0.ravel()] tree = spatial.cKDTree(data)#, boxsize=boxsize) # Query particle pairs less than desired radius
# close this output bb.close() # overwrite number of time outputs to read (for testing) #nt = 5000 #t_end = 50.0 #################################################################### # average particle velocity over all particles as a function of time #################################################################### # open, read, and close first realization to find particle number timeseries = bb.init(ensemble[-1] + "/output") bb.open(timeseries[0]) np = len(bb.read_part_position()[0]) # [0] ==> x-component bb.close() # create particle lists U = numpy.zeros(nt) V = numpy.zeros(nt) W = numpy.zeros(nt) T = numpy.zeros(nt) # realization counter rcount = 0 percent = 0 dpercent = 100. / len(ensemble) / nt for realization in ensemble: rcount = rcount + 1 timeseries = bb.init(realization + "/output")