ParaView in Batch Mode

These tutorials will demonstrate how to perform a ParaView post-processing operation in batch mode on the Rescale platform. This first tutorial will assume that you have an existing OpenFOAM-type solution and a workflow in ParaView you would like to adapt to Batch mode. The second tutorial will address complex workflows and running ParaView with OpenFOAM in a single job.

Note, in this document, the term OpenFOAM will be used to cover OpenFOAM+, FOAM Extend, Caelus and other OpenFOAM based packages.

Please contact us if you’re having trouble.


Creating a ParaView Python script

In order to utilize ParaView in batch, you will first have to develop a Python script to perform all the necessary ParaView visualization operations. You can develop one from scratch, but if you are unfamiliar with the ParaView Python based scripting language, you can start from a working “trace” of a procedure developed in the GUI. You can then modify and generalize the script as you see fit. Here, we will briefly discuss the steps required to build a ParaView “trace” as a template script.

  • First, ensure that you have a OpenFOAM case directory with the mesh (constant/polyMesh) and at least one solution set (time-step/iteration)
  • Create a file with the extension of .foam in the OpenFOAM case directory
    • A file with this extension allows ParaView to identify the solution file format and directory structure of the case as an OpenFOAM one (use .foam for Caelus solutions as well)
    • Neither the name of this .foam file nor the contents are important
    • We will use an empty file named cylinder.foam by executing the following command in the OpenFOAM case directory:
      • touch cylinder.foam
    • Note that the ParaView Pipeline object for this solution will be identified by this name, so feel free to use any type of descriptive moniker (i.e. 0.foam, bike_Re1e6.foam, airfoil_alpha10.foam, etc). However, this moniker will be embedded in the script and must always correspond with the .foam filename.
  • Create a template ParaView Python “trace” by recording commands from the GUI
    • Launch ParaView either locally or via a Rescale Desktop
    • From the file menu select Tools > Start Trace
  • Start trace
    • Select Trace Options
      • Any level of Properties to Trace on Create should be sufficient, but either any *modified* properties or any *user-modified* properties result in a much more readable and easily edited script
      • Show Incremental Trace is also a good option to check to see what corresponding commands are generated from GUI inputs
      • Click OK to begin the traceSelect trace options
    • Open the solution with the Open File icon on the toolbar or from File > Open…
      • Select the cylinder.foam file created earlier in the OpenFOAM case directory
    • Perform all of the visualization and post processing steps you require
      • Save screenshots by selecting File > Save Screenshot… and entering an appropriate filename
        • Remember that you must export images during the visualization steps where you want to have images generated, otherwise nothing will be saved when the script is run
      • Here, we will produce streamlines and field contours of pressure and velocity magnitude
      • Stop the trace recording by selecting Tools > Stop Trace
    • Stop trace
      • If you didn’t select Show Incremental Trace earlier, ParaView should now spawn a text editor with the trace or Python script commands in place
    • Save this file as your template script, here we will use pv_paraview.py
    • Make modifications and edits to this file as you see fit
    • Change absolute file paths to relative paths in the script
      • Ensure that all paths including output images are written to a valid relative path
        • For example /OpenFOAM-4.1/cases/cylinder/run01/cyl_pressure.png to cyl_pressure.png
      • Test your script by renaming the case directory to ensure all the absolute paths have been removed
  • Once you have modified your script sufficiently, be sure to test it locally to ensure it behaves properly
    • In ParaView go to: Tools > Python Shell
    • Select the Run Script button
    • Select the Python script file you have created
    • Ensure that the created output files are what you expected

Again, it is critical to correct the recorded trace ParaView from absolute file paths to relative paths (for both input and output files).

Zero Time Step

One thing to note is that ParaView in batch mode seems to ignore solutions residing in the 0 folder, regardless of *.SkipZeroTime = 0 setting within the script. Rename this to another time step (i.e. 1, 20, 1000, etc) if this is an issue. This will be evidenced by the renders not including the flow solution data in the resultant images.

Submit a ParaView batch run

With a working ParaView Python script prepared, we can now submit it as a batch job. You can refer to our Basic Job Tutorial if you would like more details about submitting a job.

  • Create a + New Job on the Rescale Platform
  • Include the OpenFOAM solution (cylinder_results.tgz) and ParaView Python script (pv_rescale.py here) as Input Files
  • Select ParaView from the Software Settings page
  • In the Analysis Options Command:
touch cylinder.foam
pybatch pv_rescale.py
  • Note that the cylinder.foam file is being created here. You may skip this if it is already included with the OpenFOAM solution files
  • Choose an appropriate core-type and number of cores. For this case we will select a single Emerald core
  • Review your job settings
  • Submit your job
  • On the Results page, you should be able to preview the output image(s) by clicking on the screen icon next to the filename
    Results page
Image preview

The previous tutorial assumed that an OpenFOAM case had been run before the ParaView post-processing step was performed. The Rescale platform allows for more complex workflows by including multiple software analysis methods in a single job. You can use this feature to perform an OpenFOAM solution and ParaView post-processing (or in-situ) analysis in a single Rescale job submission.

  • Input Files
    • Include files for a OpenFOAM run along with a ParaView Python script
  • Software Settings
    • On the Software Settings page first select OpenFOAM and set up the command as you normally would
    • Now select the “+ Add Software” button next to the Configure Software Settings title
    • This should create an additional Select Software tab next to the original OpenFOAM tabAdd ParaView software
    • Type ParaView into the “Search software here…” field and select ParaView
  • Both softwares selected
    • Configure the Command for ParaView as described previously
    • The software analysis methods will start from the left tab and proceed towards the right, so here, ensure that the ParaView tab follows the OpenFOAM tab
    • For an in-situ analysis, replace the Command associated with the Software with a single script or series of commands that runs your workflow
  • Select your preferred Hardware Settings and review your settings
  • Submit your job
  • If it is configured properly, the OpenFOAM command should run followed by the ParaView batch run as a single job
  • If this is an in-situ analysis, once the image is generated, you should be able to Preview the results as the job is running
    • On the Job Status page, filter the output files, and select the appropriate image file:
      In-situ preview