Esempio n. 1
0
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()
Esempio n. 2
0
############################################################
# visit each realization to find minimum simulation duration
############################################################

# maximum time of shortest realization
t_end = 10e10;

# number of time outputs
nt = 0;

for realization in ensemble:
  timeseries = bb.init(realization + "/output")[int(timestart/DT_out):]

  # open final output in timeseries and read time for comparison
  bb.open(timeseries[-1])
  t_tmp = bb.read_time()
  if t_tmp < t_end:
    t_end = t_tmp
    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
####################################################################
Esempio n. 3
0
#!/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()
# Get nparts
bbparts.open(times[0])
nparts = bbparts.read_nparts()
bbparts.close()

# Init data arays
u = np.zeros((len(times), nparts))
v = np.zeros((len(times), nparts))
w = np.zeros((len(times), nparts))
t = np.zeros(len(times))

# Loop over time and pull data
for tt, time in enumerate(times):
    bbparts.open(time)

    t[tt] = bbparts.read_time()

    (u[tt, :], v[tt, :], w[tt, :]) = bbparts.read_part_velocity()

    #print(np.mean(u[tt,:]), np.mean(v[tt,:]), np.mean(w[tt,:]))

    bbparts.close()

# Plot
fig = plt.figure()

ax1 = fig.add_subplot(311)
plt.plot(t, u)
plt.plot(t, np.mean(u, 1), 'ko-')
plt.xlabel("$t$")
plt.ylabel("$u$")
Esempio n. 5
0
############################################################
# visit each realization to find minimum simulation duration
############################################################

# maximum time of shortest realization
t_end = 10e10;

# number of time outputs
nt = 0;

for realization in ensemble:
  timeseries = bb.init(realization + "/output")

  # open final output in timeseries and read time for comparison
  bb.open(timeseries[-1])
  t_tmp = bb.read_time()
  if t_tmp < t_end:
    t_end = t_tmp
    nt = len(timeseries)

  # 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
####################################################################