Skip to content

Latest commit

 

History

History
137 lines (89 loc) · 4.8 KB

rendering.md

File metadata and controls

137 lines (89 loc) · 4.8 KB

High-quality Rendering on Eagle With ParaView

How to use ParaView in batch mode to generate single frames and animations on Eagle

Building PvBatch Scripts in Interactive Environments

  1. Begin by connecting to an Eagle login node:

    ssh {username}@eagle.hpc.nrel.gov
    
  2. Request an interactive compute session for 60 minutes):

    salloc -A {allocation} -t 60 
    

    Note: Slurm changes in January 2022 resulted in the need to use salloc to start your interactive session, since we'll be running pvbatch on the compute node using srun in a later step. This "srun-inside-an-salloc" supercedes the previous Slurm behavior of "srun-inside-an-srun", which will no longer work.

  3. Once the session starts, load the appropriate modules:

    module purge
    module load paraview/osmesa
    

    Note: In this case, we select the paraview/osmesa module as opposed to the default ParaView build, as the osmesa version is built for rendering using offscreen methods suitable for compute nodes.

  4. and start your render job:

    srun -n 1 pvbatch --force-offscreen-rendering render_sphere.py
    

    where render_sphere.py is a simple ParaView Python script to add a sphere source and save an image.

Transitioning to Batch Post-Processing

Tweaking the visualization options contained in the pvrender.py file inevitably requires some amount of trial and error and is most easily accomplished in an interactive compute session like the one outlined above. Once you feel that your script is sufficiently automated, you can start submitting batch jobs that require no user interaction.

  1. Prepare your script for sbatch. A minimal example of a batch script named batch_render.sh could look like:

    #!/bin/bash
    
    #SBATCH --account={allocation}
    #SBATCH --time=60:00
    #SBATCH --job-name=pvrender
    #SBATCH --nodes=2
    
    module purge
    module load paraview/osmesa
    
    srun -n 1 pvbatch --force-offscreen-rendering render_sphere.py 1 &
    srun -n 1 pvbatch --force-offscreen-rendering render_sphere.py 2 &
    srun -n 1 pvbatch --force-offscreen-rendering render_sphere.py 3 &
    
    wait
    

    where we run multiple instances of our dummy sphere example, highlighting that different options can be passed to each to post-process a large batch of simulated results on a single node. Note also that for more computationally intensize rendering or larger file sizes (e.g., tens of millions of cells) the option -n 1 option can be set as suggested in the client-server guide.

  2. Submit the job and wait:

    sbatch batch_render.sh
    

Tips on Creating the PvBatch Python Script

Your ParaView python script can be made in a number of ways. The easiest is to run a fresh session of ParaView (use version 5.x on your local machine) and select "Tools→Start Trace," then "OK". Perform all the actions you need to set your scene and save a screenshot. Then select "Tools → Stop Trace" and save the resulting python script (we will use render_sphere.py in these examples).  

Here are some useful components to add to your ParaView Python script.

  • Read the first command-line argument and use it to select a data file to operate on.

    import sys
    doframe = 0
    if len(sys.argv) > 1:
        doframe = int(sys.argv[1])
    infile = "output%05d.dat" % doframe
    

    Note that pvbatch will pass any arguments after the script name to the script itself. So you can do the following to render frame 45:

    srun -n 1 pvbatch --force-offscreen-rendering render_sphere.py 45
    

    You could programmatically change this value inside the batch_render.sh script, your script would need to iterate using something like:

    for frame in 45 46 47 48
    do
        srun -n 1 pvbatch --force-offscreen-rendering render_sphere.py $frame
    done
    
  • Set the output image size to match FHD or UHD standards:

    renderView1.ViewSize = [3840, 2160]
    renderView1.ViewSize = [1920, 1080]
    
 
  • Don't forget to actually render the image!

    pngname = "image%05d.png" % doframe
    SaveScreenshot(pngname, renderView1)