2.4.1. Example: Pressure Calculation on Multiple Files using Batch Mode

This example calculates the value of pressure at a point in each of three results files.

The purpose of this example is for demonstration only. You will deal with only three results files in this case, and it would be faster to produce the output by using the graphical user interface. However, these features can be useful in situations where a large number of results files need to be processed at once.

In order to carry out this procedure, you will make use of session files, power syntax and the Command Editor dialog box. You could use the results from any file by making the appropriate substitutions in the following example.

  1. Place three results files (<resfile1>, <resfile2>, <resfile3>) in your working directory. For this example, in all three results files the location 0, 0, 0 must be in the solution domain.

  2. Create a session file based on a results file.

    1. Start CFD-Post and select File > Load Results. Select the results file and click Open.

    2. Select Session > New Session from the main menu.

      For details, see New Session Command.

    3. Enter batchtest.cse as the session file name and click Save.

    4. Select Session > Start Recording from the main menu to begin recording the session file commands.

    5. Select Insert > Location > Point and accept the default name Point 1.

    6. Click Apply to create the point at location 0, 0, 0.

      You will now use Power Syntax to find the value of pressure at Point 1, and print it to the command line. In addition to printing the value of pressure, it would be useful to know the name of the results file. You will make use of the DATA READER object to find the name of the current results file.

    7. Select Tools > Command Editor.

    8. Enter the following into the command window:

      ! $filePath = getValue("DATA READER","Current Results File");
      ! $pressureVal = probe("Pressure","Point 1");
      ! print "\nFor $filePath, Pressure at Point 1 is $pressureVal\n";
      

      Note:  If you copy the text above into the Command Editor, ensure that the exclamation points are at the beginning of lines.


    9. Click Process to process the commands.

    10. Check the terminal window to make sure the command worked as desired.

    11. Select Session > Stop Recording from the main menu to stop recording the session file.

  3. This completes the first part of the example. You may want to close down CFD-Post at this time.

  4. You can now run the session file on any number of results files using the following command:

    <CFDPOSTROOT>/bin/cfdpost -batch batchtest.cse <resfile>
    

    where <resfile> is the name of your results file.

    To load multiple files, you can list the filenames at the end of the command. For example:

    cfdpost -batch batchtest.cse <resfile1> <resfile2> <resfile3>
    

For a very large number of results files, a simple script can be used to pass filenames as command line arguments. As an example, this C shell script would pass arguments as results file names to the CFD-Post command line:

#!/bin/csh
foreach file ($argv)
<CFDPOSTROOT>/cfdpost -batch batchtest.cse $file
end