Beispiel #1
0
#  limitations under the License.
#
#  Please contact the Johns Hopkins University to use Bluebottle for
#  commercial and/or for-profit applications.
################################################################################

#!/usr/bin/env python

# bluebottle_reader python module example code

import sys, getopt
import numpy as np
import bluebottle_flow_reader as bbflow

# initialize the reader
times = bbflow.init("~/scratch/tmp-cgns")

# Pull grid positions
(x, y, z) = bbflow.read_flow_position()

# visit all outputted time values
for time in times:
    # open the CGNS file for this particular output time
    bbflow.open(time)

    # read the CGNS file
    t = bbflow.read_time()
    (u, v, w) = bbflow.read_flow_velocity()

    print("t =", t)
if len(sys.argv) >= 2:    # output directory given
  data_dir = sys.argv[1]

  if len(sys.argv) >= 3:  # start time given
    t_start= sys.argv[2]

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()

times = bbparts.init(data_dir)
timesf = bbflow.init(data_dir)

bbflow.open(timesf[0])
rho,nu = bbflow.read_flow_params()
bbflow.close()

bbparts.open(times[0])
nparts = bbparts.read_nparts()
bbparts.close()

vel = np.zeros((len(times), nparts))
zvel = np.zeros((len(times), nparts))
t = np.zeros(len(times))
Rep = np.zeros((len(times), nparts))
r = np.zeros(nparts)