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.
Place three results files (
,<resfile1>
,<resfile2>
) in your working directory. For this example, in all three results files the location 0, 0, 0 must be in the solution domain.<resfile3>
Create a session file based on a results file.
Start CFD-Post and select File > Load Results. Select the results file and click .
Select Session > New Session from the main menu.
For details, see New Session Command.
Enter
batchtest.cse
as the session file name and click Save.Select Session > Start Recording from the main menu to begin recording the session file commands.
Select Insert > Location > Point and accept the default name
Point 1
.Click
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 theDATA READER
object to find the name of the current results file.Select Tools > Command Editor.
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.
Click Process to process the commands.
Check the terminal window to make sure the command worked as desired.
Select Session > Stop Recording from the main menu to stop recording the session file.
This completes the first part of the example. You may want to close down CFD-Post at this time.
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
is the name of your results file.<resfile>
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