Summary

In typical CFD analyses, analyzing the amount of reverse flow or flow disturbance is a common occurrence. If the region of interest is aligned with a coordinate direction, or at least fixed, one can simply analyze a particular component, or components of the velocity field. However, it is quite common that this direction of interest changes within the geometry.

This tutorial illustrates the visualization and quantification of reverse flow through not only an arbitrary duct, but one that changes is direction.

The duct is not aligned to a coordinate system, so a spline is used to specify the normal definition of a clip plane. The flow through the plane is quantified in each direction, and thus the amount of reverse flow can be quantified. We will also demonstrate how to loop through and create a graph of the reverse flow as well.

Finally, we will use UV texture mapping with EnSight to turn translucent the regions of the domain where we have positive flow, and make opaque the regions of reverse flow, thus visualizing this region of reverse flow.

A video tutorial of this exercise can be viewed from this location: http://www.ceisoftware.com/screencasts/Reverse_Flow_Duct/Reverse_Flow_Duct.html

Background

A basic three dimensional duct was created for this exercise. The inlet flowfield was specified to have a large radial gradient in velocity, to ensure that the flow separated during the duct’s turn and expansion in area.

Step 1: Determining a means to direct “reverse” flow. In this instance, we will use a spline to specify the centerline of the duct. The clip plane will be tied to always be normal to this spline, and thus normal to the duct.

The spline can be a) read in from a file, b) generated from a streamline, or c) clicked manually with the mouse. In this instance, I know the centerline of the duct, and this read in the spline from a file (spline.txt).

Step 2: Create a clip plane using the Plane tool, and tie the clip plane to the spline. Once the plane clip has been created, under the Advanced Option for the clip, you can specify to tie the clip to a spline.

You now have a clip plane, which can be moved along the spline, and is now always normal to the spline, and thus the duct.

Step 3: Create a new scalar field which represents the flow through the plane. In particular, the scalar field should be signed, such that positive value is positive flow, while negative value is negative flow (reverse flow). A python routine here is quite handy to keep things tidy, and for future reference/modification.

*# Commands session to calculate negative and postive flow through a plane*

*#*

*# Part for plane: 5*

*ensight.variables.activate("VEL")*

*# create a momentum vector*

*ensight.part.select_all()*

*ensight.variables.evaluate("Momentum = VEL * 1.205")*

* *

*ensight.part.select_begin(5)*

*# a. create a normal vector for the plane*

*ensight.variables.evaluate("Normal_Vect = Normal(plist)")*

*# b. Dot the normal with the velocity to get a normal component vector*

*ensight.variables.evaluate("ScalarField = DOT(Normal_Vect,Momentum)")*

*# c. create a positive flow variable where this is positive*

*ensight.variables.evaluate("PosFlow = GT(ScalarField,0)")*

*# d. create a negative flow variable where this is negative*

*ensight.variables.evaluate("NegFlow = LT(ScalarField,0)")*

*#*

*# e. integrate over the surface to obtain a positive and neg flow rate*

*ensight.variables.evaluate("PosFlowRate = IntegralSurface(plist,PosFlow)")*

*ensight.variables.evaluate("NegFlowRate = IntegralSurface(plist,NegFlow)")*

*ensight.variables.evaluate("NetFlowRate = IntegralSurface(plist,ScalarField)")*

*# f. calculate a percentage*

*ensight.variables.evaluate("NegPerc = NegFlowRate / NetFlowRate * 100")*

*ensight.variables.evaluate("PosPerc = 100.0 + NegPerc")*

One can see here that “ScalarField” is just the Normal of the Plane dotted with the Velocity vector. We use the “GT” and “LT” math functions to separate out this scalar field into two new variables (one above zero, and one below zero). Finally, integration of these quantities on the plane results in a new constant, with the value equivalent to the amount of positive and reverse flow.

Step 4: Generate a query along the length of the spline for a graph.

Now that we have these values on the plane, we want to quantify this along the length of the duct. You could simply create an annotation, with these constants, but a graph would be more useful. The UserDefinedTool "Part Constant Query" can be used to take this value, and generate a graph query as a result.

You can see where Scalar field is negative, we have reverse flow. The graph indicates that we have a maximum of about 15% reverse flow, at the location of 32% along the duct.

Step 5: Visualization of Reverse Flow.

Now that you have a graph, it would be advantageous to visualize this area all at once. To do so, I create 200 section cuts along the length of the pipe. This is quite easy, again using Python to loop through the generation of a single clip, and repeating:

*# create a loop to generate clips along spline*

*numy = 200*

*ystart = 0.001*

*yinc = 1.0/200.0*

*for j in range(numy):*

* ypos = ((j)*yinc)+ystart*

* npart = j + 1 + 6*

* ensight.clip.select_default()*

* ensight.part.modify_begin()*

* ensight.clip.extents("infinite")*

* ensight.clip.tool("plane")*

* ensight.part.modify_end()*

* ensight.part.select_begin(1)*

* ensight.clip.begin()*

* ensight.clip.domain("intersect")*

* ensight.clip.tool("plane")*

* ensight.clip.end()*

* ensight.clip.create()*

* ensight.part.select_begin(npart)*

* ensight.part.modify_begin()*

* ensight.clip.spline_name("new_spline0")*

* ensight.part.modify_end()*

* ensight.part.modify_begin()*

* ensight.clip.spline_location(ypos)*

* ensight.part.modify_end()*

*#end of loop*

*#end of routine*

Within the routine, you can see the “numy”, “ystart” and “yinc” to control the location of the new clip plane each time.

With 200 clips created, I re-group them into a single part (Called “Group Clips”), and then do a similar calculation of “ScalarField”, but now on this new grouped clip plane:

*# Commands session to calculate negative and postive flow through a plane*

*#*

*#*

*ensight.variables.activate("VEL")*

*# create a momentum vector*

*ensight.part.select_all()*

*ensight.variables.evaluate("Momentum2 = VEL * 1.205")*

* *

*ensight.part.select_byname_begin("(CASE:Case 1)GROUP: Group Clips")*

*# a. create a normal vector for the plane*

*ensight.variables.evaluate("Normal_Vect2 = Normal(plist)")*

*# b. Dot the normal with the velocity to get a normal component vector*

*ensight.variables.evaluate("ScalarField2 = DOT(Normal_Vect2,Momentum2)")*

*# c. create a positive flow variable where this is positive*

*ensight.variables.evaluate("PosFlow2 = GT(ScalarField2,0)")*

*# d. create a negative flow variable where this is negative*

*ensight.variables.evaluate("NegFlow2 = LT(ScalarField2,0)")*

*#*

*# Create a new scalar for doing transparency*

*ensight.variables.evaluate("ScalarField_node = ElemToNode(plist,ScalarField2)")*

*ensight.variables.evaluate("Max = Max(plist,ScalarField2)")*

*ensight.variables.evaluate("Min = Min(plist,ScalarField2)")*

*ensight.variables.evaluate("T_variable = ScalarField_node/(Max-Min)*(-1.0)")*

You will also note that I create a “T_variable” here, which is the normalized ScalarField function, reversed about zero so that values above zero are now regions of reverse flow.

With this T-Variable, I now have a variable that I can adjust the transparency. I then adjust the texture for the group of clips part to follow a dual gradient image file (dual_gradient.png), and adjust the values in the texture window accordingly:

The result is adjusting the opacity of the clip planes based on the variable of ScalarField. The resultant picture now looks like this, with all 200 clip planes:

You can now visualize the locations of reverse flow, along with quantifying the amount of reverse flow as a function of distance along the duct.

If interested to perform this analysis on your own, the following link contains the dataset used, spline used, and python files referenced above.

Reverse Flow Quantification Dataset

## Comments