Beispiel #1
0
def main(args):
  """Plots the the velocity, pressure, or vorticity fields at saved time-steps
  for a two-dimensional simulation.
  """
  simulation = Simulation(directory=args.directory, software=args.software)
  time_steps = simulation.get_time_steps(time_steps_range=args.time_steps_range)
  simulation.read_grid()
  bodies = [Body(path) for path in args.body_paths]

  if args.subtract_simulation:
    info = dict(zip(['software', 'directory'], 
                    args.subtract_simulation))
    other = Simulation(**info)
    other.read_grid()

  for time_step in time_steps:
    simulation.read_fields([args.field_name], time_step, 
                           periodic_directions=args.periodic_directions)
    
    field_name = (args.field_name if not args.subtract_simulation
                                  else args.field_name+'-subtracted')
    if args.subtract_simulation:
      other.read_fields([args.field_name], time_step, 
                        periodic_directions=args.periodic_directions)
      simulation.subtract(other, args.field_name, field_name)

    simulation.plot_contour(field_name,
                            field_range=args.range,
                            filled_contour=args.filled_contour,
                            view=args.bottom_left+args.top_right,
                            bodies=bodies,
                            save_name=args.save_name,
                            width=args.width, 
                            dpi=args.dpi)
Beispiel #2
0
def main(args):
    """Writes the numerical solution into .vtk files."""
    # parse command-line
    simulation = Simulation(directory=args.directory, software=args.software)

    time_steps = simulation.get_time_steps(args.case_directory,
                                           args.time_steps)

    simulation.read_grid()

    for time_step in time_steps:
        if 'velocity' in args.field_names:
            simulation.read_fields(
                ['x-velocity', 'y-velocity', 'z-velocity'],
                time_step,
                periodic_directions=args.periodic_directions)
            # need to get velocity at cell-centers, not staggered arrangement
            simulation.get_velocity_cell_centers()
            simulation.write_vtk('velocity',
                                 view=[args.bottom_left, args.top_right],
                                 stride=args.stride)
        if 'pressure' in args.field_names:
            simulation.read_fields(['pressure'], time_step)
            simulation.write_vtk('pressure',
                                 view=[args.bottom_left, args.top_right],
                                 stride=args.stride)
Beispiel #3
0
def main(args):
    """Plots and writes the velocity components at the centerline of the cavity
  and compares with experimental results form Ghia et al. (1982).
  """
    # register simulation
    simulation = Simulation(directory=args.directory, software=args.software)

    # get time-step
    if not args.time_step:
        args.time_step = simulation.get_time_steps()[-1]

    simulation.read_grid()
    simulation.read_fields(['x-velocity', 'y-velocity'], args.time_step)

    # read validation data from Ghia et al. (1982)
    u, v = get_validation_data(args.validation_data_path, args.Re)

    software_name = {'petibm': 'PetIBM', 'cuibm': 'cuIBM'}
    plot_settings = {
        'label': software_name[args.software],
        'color': '#336699',
        'linestyle': '-',
        'linewidth': 3,
        'zorder': 10
    }
    validation_plot_settings = {
        'label': 'Ghia et al. (1982)',
        'color': '#993333',
        'linewidth': 0,
        'markeredgewidth': 2,
        'markeredgecolor': '#993333',
        'markerfacecolor': 'none',
        'marker': 'o',
        'markersize': 8,
        'zorder': 10
    }

    save_directory = os.path.join(simulation.directory, 'images')
    if not os.path.isdir(save_directory):
        os.makedirs(save_directory)
    simulation.x_velocity.plot_vertical_gridline_values(
        0.5,
        plot_settings=plot_settings,
        plot_limits=[0.0, 1.0, -0.75, 1.25],
        save_directory=save_directory,
        show=args.show,
        validation_data=(u.y, u.values),
        validation_plot_settings=validation_plot_settings)
    simulation.y_velocity.plot_horizontal_gridline_values(
        0.5,
        plot_settings=plot_settings,
        plot_limits=[0.0, 1.0, -0.75, 1.25],
        save_directory=save_directory,
        show=args.show,
        validation_data=(v.x, v.values),
        validation_plot_settings=validation_plot_settings)
def main(args):
  """Plots and writes the velocity components at the centerline of the cavity
  and compares with experimental results form Ghia et al. (1982).
  """
  # register simulation
  simulation = Simulation(directory=args.directory, 
                          software=args.software)
  
  # get time-step
  if not args.time_step:
    args.time_step = simulation.get_time_steps()[-1]
  
  simulation.read_grid()
  simulation.read_fields(['x-velocity', 'y-velocity'], args.time_step)

  # read validation data from Ghia et al. (1982)
  u, v = get_validation_data(args.validation_data_path, args.Re)

  software_name = {'petibm': 'PetIBM', 'cuibm': 'cuIBM'}
  plot_settings = {'label': software_name[args.software],
                   'color': '#336699', 'linestyle': '-', 'linewidth': 3,
                   'zorder': 10}
  validation_plot_settings = {'label': 'Ghia et al. (1982)',
                              'color': '#993333', 'linewidth': 0,
                              'markeredgewidth': 2, 'markeredgecolor': '#993333',
                              'markerfacecolor': 'none',
                              'marker': 'o', 'markersize': 8,
                              'zorder': 10}

  save_directory = os.path.join(simulation.directory, 'images')
  if not os.path.isdir(save_directory):
    os.makedirs(save_directory)
  simulation.fields['x-velocity'].plot_vertical_gridline_values(0.5,
                              plot_settings=plot_settings,
                              plot_limits=[0.0, 1.0, -0.75, 1.25],
                              save_directory=save_directory,
                              show=args.show,
                              validation_data=(u.y, u.values),
                              validation_plot_settings=validation_plot_settings,
                              style=os.path.join(os.environ['SNAKE'],
                                                 'snake', 
                                                 'styles', 
                                                 'mesnardo.mplstyle'))
  simulation.fields['y-velocity'].plot_horizontal_gridline_values(0.5,
                              plot_settings=plot_settings,
                              plot_limits=[0.0, 1.0, -0.75, 1.25],
                              save_directory=save_directory,
                              show=args.show,
                              validation_data=(v.x, v.values),
                              validation_plot_settings=validation_plot_settings,
                              style=os.path.join(os.environ['SNAKE'],
                                                 'snake', 
                                                 'styles', 
                                                 'mesnardo.mplstyle'))
Beispiel #5
0
def main(args):
    """Writes the numerical solution into .vtk files."""
    # parse command-line
    simulation = Simulation(directory=args.directory, software=args.software)

    time_steps = simulation.get_time_steps(args.case_directory, args.time_steps)

    simulation.read_grid()

    for time_step in time_steps:
        if "velocity" in args.field_names:
            simulation.read_fields(
                ["x-velocity", "y-velocity", "z-velocity"], time_step, periodic_directions=args.periodic_directions
            )
            # need to get velocity at cell-centers, not staggered arrangement
            simulation.get_velocity_cell_centers()
            simulation.write_vtk("velocity", view=[args.bottom_left, args.top_right], stride=args.stride)
        if "pressure" in args.field_names:
            simulation.read_fields(["pressure"], time_step)
            simulation.write_vtk("pressure", view=[args.bottom_left, args.top_right], stride=args.stride)