import snake from snake.openfoam.simulation import OpenFOAMSimulation print('\nPython version:\n{}'.format(sys.version)) print('\nsnake version: {}\n'.format(snake.__version__)) directory = os.path.join(os.environ['HOME'], 'snakeReproducibilityPackages', 'openfoam', 'gmsh', 'Re2000AoA35') simulation = OpenFOAMSimulation(directory=directory) simulation.plot_field_contours_paraview('vorticity', field_range=(-5.0, 5.0), view=(-5.0, -8.0, 10.0, 2.0), times=(52.0, 52.0, 1.0), width=600, colormap='RdBu_r') images_directory = os.path.join(directory, 'images', 'vorticity_-5.00_-8.00_10.00_2.00') file_name_source = 'vorticity052.00.png' file_name_destination = 'openfoam_vorticity52Re2000AoA35_gmshZeroGradient.pdf' # copy the .png file shutil.copy(os.path.join(images_directory, file_name_source), os.path.join(os.getcwd(), file_name_destination.replace('.pdf', '.png'))) # convert into .pdf file os.system('convert {} {}'.format(os.path.join(images_directory, file_name_source),
""" Plots the 2D pressure field from a OpenFOAM simulation at given times using the visualization software ParaView. """ from snake.openfoam.simulation import OpenFOAMSimulation simulation = OpenFOAMSimulation() simulation.plot_field_contours_paraview('pressure', field_range=(-1.0, 0.5), view=(-2.0, -5.0, 15.0, 5.0), times=(0.0, 100.0, 2.0), width=800)
""" Plots the 2D vorticity field from a OpenFOAM simulation at given times using the visualization software ParaView. """ from snake.openfoam.simulation import OpenFOAMSimulation simulation = OpenFOAMSimulation() simulation.plot_field_contours_paraview('vorticity', field_range=(-5.0, 5.0), view=(-2.0, -5.0, 15.0, 5.0), times=(0.0, 100.0, 2.0), width=800)
import snake from snake.openfoam.simulation import OpenFOAMSimulation print('\nPython version:\n{}'.format(sys.version)) print('\nsnake version: {}\n'.format(snake.__version__)) directory = os.path.join(os.environ['HOME'], 'snakeReproducibilityPackages', 'openfoam', 'gmsh', 'Re2000AoA35') simulation = OpenFOAMSimulation(directory=directory) simulation.plot_field_contours_paraview('pressure', field_range=(-1.0, 0.5), view=(-2.0, -3.0, 15.0, 3.0), times=(52.0, 53.0, 1.0), width=600, colormap='viridis') # locate images of interest images_directory = os.path.join(simulation.directory, 'images', 'pressure_-2.00_-3.00_15.00_3.00') file_names = ['pressure052.00.png', 'pressure053.00.png'] source_paths = [os.path.join(images_directory, name) for name in file_names] # copy .png files here destination_paths = [os.path.join(os.getcwd(), 'openfoam_pressure52Re2000AoA35_gmshZeroGradient.png'), os.path.join(os.getcwd(), 'openfoam_pressure53Re2000AoA35_gmshZeroGradient.png')] for s, d in zip(source_paths, destination_paths):
# file: plotPressure.py # author: Olivier Mesnard ([email protected]) # description: Plots the 2D pressure field. # Run this script from the simulation directory. from snake.openfoam.simulation import OpenFOAMSimulation simulation = OpenFOAMSimulation() simulation.plot_field_contours_paraview('pressure', field_range=(-1.0, 0.5), view=(-2.0, -5.0, 15.0, 5.0), times=(0.0, 100.0, 2.0), width=800)
default=os.path.join(script_directory, 'map.yaml'), help='file containing the list of simulation directories') parser.add_argument('--save-dir', dest='save_directory', type=str, default=script_directory, help='directory where to save the figures') args = parser.parse_args() with open(args.map, 'r') as infile: dirs = yaml.load(infile) simulation_directory = dirs['openfoam_vorticity52Re2000AoA35_gmshZeroGradient']['Re2000AoA35'] simulation = OpenFOAMSimulation(directory=simulation_directory) simulation.plot_field_contours_paraview('vorticity', field_range=(-5.0, 5.0), view=(-5.0, -8.0, 10.0, 2.0), times=(52.0, 52.0, 1.0), width=1000, colormap='RdBu_r') simulation.plot_field_contours_paraview('vorticity', field_range=(-5.0, 5.0), view=(2.20, -7.30, 2.80, -6.70), times=(52.0, 52.0, 1.0), width=300, colormap='RdBu_r', display_scalar_bar=False, display_time_text=False, display_mesh=True) file_path_source_1 = os.path.join(simulation.directory, 'images', 'vorticity_-5.00_-8.00_10.00_2.00',
import os import sys import shutil import snake from snake.openfoam.simulation import OpenFOAMSimulation print('\nPython version:\n{}'.format(sys.version)) print('\nsnake version: {}\n'.format(snake.__version__)) directory = os.path.join(os.environ['HOME'], 'snakeReproducibilityPackages', 'openfoam', 'gmsh', 'Re2000AoA35') simulation = OpenFOAMSimulation(directory=directory) simulation.plot_field_contours_paraview('pressure', field_range=(-1.0, 0.5), view=(-2.0, -3.0, 15.0, 3.0), times=(52.0, 53.0, 1.0), width=600, colormap='viridis') # locate images of interest images_directory = os.path.join(simulation.directory, 'images', 'pressure_-2.00_-3.00_15.00_3.00') file_names = ['pressure052.00.png', 'pressure053.00.png'] source_paths = [os.path.join(images_directory, name) for name in file_names] # copy .png files here destination_paths = [ os.path.join(os.getcwd(), 'openfoam_pressure52Re2000AoA35_gmshZeroGradient.png'), os.path.join(os.getcwd(), 'openfoam_pressure53Re2000AoA35_gmshZeroGradient.png') ]
# file: plotVorticitySnake.py # author: Olivier Mesnard ([email protected]) # description: Plots the 2D vorticity field near the snake. # Run this script from the simulation directory. from snake.openfoam.simulation import OpenFOAMSimulation simulation = OpenFOAMSimulation() simulation.plot_field_contours_paraview( "vorticity", field_range=(-5.0, 5.0), view=(-0.75, -1.0, 1.50, 1.0), times=(0.0, 100.0, 2.0), width=800 )
# file: plotVorticity.py # author: Olivier Mesnard ([email protected]) # description: Plots the 2D vorticity field. # Run this script from the simulation directory. from snake.openfoam.simulation import OpenFOAMSimulation simulation = OpenFOAMSimulation() simulation.plot_field_contours_paraview('vorticity', field_range=(-5.0, 5.0), view=(-2.0, -5.0, 15.0, 5.0), times=(0.0, 100.0, 2.0), width=800)