Python diffing
Here are some basic examples of differencing with Python...
(All of these script fragments assume that a database has already been opened.)
Contents
Integrating differences
This will calculate the difference in pressure between the currently open file and the file a.00000:
>> DefineScalarExpression("p_diff", "abs(p-conn_cmfe(<a.00000:p>, mesh_3d))") >> AddPlot("Pseudocolor", "p_diff") >> DrawPlots() >> Query("Weighted Variable Sum") >> diff = GetQueryOutputValue()
Identifying asymmetries
This will identify the zone that contains the biggest different across the symmetry plane X=Y:
>> DefineScalarExpression("p_diff2", "symm_plane(p, [1, -1, 0, 0, 0, 0])" >> AddPlot("Pseudocolor", "p_diff2")} >> DrawPlots() >> Query("MinMax")
Calculating compression
This will calculate the maximum compression that a zone undergoes, assuming that there has been no remapping:
>> DefineScalarExpression("compression", "volume(mesh_3d) / conn_cmfe(volume(<[0]i:mesh_3d>), mesh_3d)") >> AddPlot("Pseudocolor", "compression") >> DrawPlots() >> Query("MinMax")
Differencing Two Independent Files
This will allow you to look at the differences between two separate files, f1 and f2. (Note that f1 and f2 probably expand to long, fully qualified file names.) f1 and f2 may have identical domain decompositions, or they may be totally different.
>> OpenDatabase(f1) >> DefineScalarExpression("p_diff3", "p - pos_cmfe(<f2:p>, mesh_3d, -100)") >> AddPlot("Pseudocolor", "p_diff3") >> DrawPlots()
Note that this will take p from the mesh of f1 and subtract p from
the mesh of f2. The result will be placed on the mesh mesh_3d of f1, since
f1 is the open database. Further, note that a value of -100 will
be placed anywhere f1 's mesh is not covered by f2 's.
Time averages
This assumes that you have a database of time slices and that you want to look at the difference between the tenth time slice and the last time slice for a variable named p.
>> TimeSliderSetState(10) >> Query("Time") >> t1 = GetQueryOutputValue() >> lastTime = TimeSliderGetNStates() - 1 >> TimeSliderSetState(lastTime) >> Query("Time") >> t2 = GetQueryOutputValue() >> defn = "1/(%f - %f) * (%f*p - %f*conn\_cmfe(<[10]i:p>, mesh\_3d))" %(t2,t1,t2,t1) >> DefineScalarExpression("time\_avg", defn)} >> AddPlot("Pseudocolor", "time\_avg")} >> DrawPlots()