Computational Fluid Dynamics: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
No edit summary
No edit summary
 
(16 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Visualizing Computational Fluid Dynamics=
=Visualizing Computational Fluid Dynamics=
This tutorial shows common visualization techniques for cfd datasets.  We will be using the dataset disk_out_ref.exo, found in Paraview under File/ Open/ Examples.  It has a vector field in it called V.
This tutorial shows common visualization techniques for cfd datasets.  We will be using the dataset disk_out_ref.exo, found in Paraview under File/ Open/ Examples.  It has a vector field in it called V.  Note that we will reset session (i.e., start from scratch) every section.


==Slices==
==Slices==
Line 12: Line 12:
*'''View → Color Map Editor → Presets''' (the little envelope with a heart)''' → Turbo'''.
*'''View → Color Map Editor → Presets''' (the little envelope with a heart)''' → Turbo'''.
*With the mouse, rotate the slices around so you can see both surfaces.
*With the mouse, rotate the slices around so you can see both surfaces.
*'''Edit → Reset Session'''.  There is also a shortcut icon just above where you have been changing colors.  It looks like a green counterclockwise snake eating it's tail.




Line 34: Line 35:
*Color by: '''temp'''.
*Color by: '''temp'''.
*'''View → Color Map Editor → Presets''' (the little envelope with a heart)''' → Black Body Radiation'''.
*'''View → Color Map Editor → Presets''' (the little envelope with a heart)''' → Black Body Radiation'''.
*'''Reset'''
 
Lets save this really cool image as a screenshot.
 
* '''File →  Save Screenshot'''.  Add a file name.  '''OK'''.  '''OK'''.
 
*'''Edit → Reset Session'''.




[[Image:cfd_streamtracer1.png|1000px]]
[[Image:cfd_streamtracer1.png|1000px]]
==Stream Tracers with Custom Source==
We want to create stream tracers from any arbitrary source.  This can be a line, spline, circle, elipse or any other curving line.  An extreme example would be a cylinder cut by a plane.
*'''File → Open → Examples → disk_out_ref.exo.'''.  On the '''Properties''' tab, click '''Apply'''.
*'''+X'''
*Change '''vtkBlockColors''' to '''Solid Color'''.  Change '''Opacity''' to '''0.3'''.
*'''Sources → Elipse'''.  '''Center'''. '''0,0,7'''.  '''Major Radius Vector''', '''3,0,0'''.  '''Ratio''', '''0.3'''. '''Apply'''.
*'''Filters → Search'''.  Type '''Tube'''.  '''Apply'''. 
*Select '''disk_out_ref.exo''' in the '''Pipeline Browser'''.
*'''Filters → Alphabetical → Stream Tracer with Custom Source'''.  Use '''Elipse''' as the seed source.  '''Apply'''. 
*Color by: '''Solid Color'''.
The image below is a merging of Stream Tracers with lines and tubes, and Stream Tracer with Custom Source.  I have also played with colors to make it look nicer.  If interested, replicating is left to the user.
*'''Edit → Reset Session'''.
[[Image:cfd_streamtracer_with_custom_source.png|1000px]]




Line 47: Line 72:
Lets create a half slice.  This will be used as the seed plane for glyphs.
Lets create a half slice.  This will be used as the seed plane for glyphs.


*'''Filters → Common → Slice'''.  Origin '''0, 0, 5'''.  Uncheck '''Show Plane'''.  '''Apply'''.   
*'''Filters → Common → Slice'''.  '''Z Normal'''.  Origin '''0, 0, 5'''.  Uncheck '''Show Plane'''.  '''Apply'''.   
*'''Filters → Common → Clip'''.  Uncheck '''Show Plane'''.  '''Apply'''.   
*'''Filters → Common → Clip'''.  Uncheck '''Show Plane'''.  '''Apply'''.   


Line 57: Line 82:
Let's put these glyphs back into context by showing the original dataset.
Let's put these glyphs back into context by showing the original dataset.


*Select '''disk_out_ref.exo''' in the Pipeline Browser.  Representation: '''wireframe'''.  On the Properties tab, change '''Opacity''' to '''0.3'''.
*Select '''disk_out_ref.exo''' in the Pipeline Browser.  Representation: '''wireframe'''.  In the '''pipeline browser''', click on the '''eyeball''' next to '''disk_out_ref.exo'''.  On the Properties tab, change '''Opacity''' to '''0.3'''.
*Use the mouse to zoom into the glyph vectors.
*Use the mouse to zoom into the glyph vectors.
*'''Edit → Reset Session'''.




Line 71: Line 97:
Lets sample over a line.
Lets sample over a line.


*'''Filters → Data Analysis → Plot over Line'''.  '''Y Axis'''.  Change the '''Z''' component of the line to '''1'''.  Change the '''Resolution''' to '''40'''.  '''Apply'''.   
*'''Filters → Data Analysis → Plot over Line'''.  '''Y Axis'''.  Change the '''Z''' component of '''Point1''' and '''Point2''' to '''1'''.  Change the '''Resolution''' to '''40'''.  '''Apply'''.   
*Close the '''LineChartView'''.
*Close the '''LineChartView'''.
*In the '''Pipeline Browser''', turn visibility off for '''disk_out_ref.exo'''.
*In the '''Pipeline Browser''', turn visibility off for '''disk_out_ref.exo'''.
Line 89: Line 115:
Let's put these glyphs back into context by showing the original dataset.
Let's put these glyphs back into context by showing the original dataset.


*Select '''disk_out_ref.exo''' in the Pipeline Browser.   On the Properties tab, change '''Opacity''' to '''0.3'''.
*Select '''disk_out_ref.exo''' in the Pipeline Browser. Click on the '''eyeball''' next to '''disk_out_ref.exo'''.  On the Properties tab, change '''Opacity''' to '''0.3'''.


Just to create a nice image, I'm going to split the views horizontally, and show this visualization also from the side.
Just to create a nice image, I'm going to split the views horizontally, and show this visualization also from the side.
Line 95: Line 121:


[[Image:cfd_fluid_velocity_profile1.png|1000px]]
[[Image:cfd_fluid_velocity_profile1.png|1000px]]
You can write the data sampled down the line to a .csv file, where you can post process it with tools such as Excel.  Here is how to do it.
*Select '''PlotOverLine''' in the Pipeline Browser.
*Split screen vertical.  '''Spreadsheet view'''.
*Now, click on the '''Export Scene''' icon, and write the '''Spreadsheet''' down to a '''.csv file'''.
Lets save this really cool image as a screenshot.
* '''File →  Save Screenshot'''.  Add a file name.  '''OK'''.  We want to save both views.  Click '''Save All Views'''.  '''OK'''.
*'''Edit → Reset Session'''.
[[Image:cfd_fluid_velocity_profile_spreadsheet.png|1000px]]
==2D plots through a fluid==
*'''File → Open → Examples → disk_out_ref.exo.'''.  On the '''Properties''' tab, click '''Apply'''.
*'''+X'''
*'''Filters → Data Analysis → Plot over Line'''.  '''Y Axis'''.  Change the '''Z''' component of '''Point1''' and '''Point2''' to '''4'''.  '''Apply'''.
*In the '''Properties Tab''', turn all variables off other than '''v_Z'''.
*Click on the '''RenderView''', the left '''view'''. 
*Select '''disk_out_ref.exo''' in the Pipeline Browser.    On the Properties tab, change '''Opacity''' to '''0.3'''.
*'''Edit → Reset Session'''.
[[Image:cfd_2d_plots.png|1000px]]
==Contours on a slice==
*'''File → Open → Examples → disk_out_ref.exo.'''.  On the '''Properties''' tab, click '''Apply'''.
*'''+X'''
*'''Filters → Common → Slice'''.  Uncheck '''Show Plane'''.  '''Apply'''.
We need the magnitude for the Contour filter.
*'''Filters → Common → Calculator'''.  Result Array Name '''vMag'''.  Formula '''mag(v)'''.  '''Apply'''.
Now, draw contours on the 2d slice.
*'''Filters → Common → Contour'''.  Contour by vMag.  Delete the '''Value''', and create a new set using the '''Add a Range of Values''' icon.  '''Apply'''.
A nice visualization is to turn visibility on for '''Slice''' and paint by '''v''', and change '''Contour''' to be a '''Solid Color''', and make that color '''White'''. 
Here is an example with additional '''streamlines''', '''tubes''' and '''glyphs'''.
*'''Edit → Reset Session'''.
[[Image:cfd_contours_on_slices.png|1000px]]




Line 100: Line 179:
==Gradient, Divergence, Vorticity and and Q Criterion==
==Gradient, Divergence, Vorticity and and Q Criterion==
The '''Gradient''' filter ('''Advanced''' Properties tab) provides Gradient, Divergence, Vorticity and and Q Criterion.  Here is am example, using disk_out_ref.exo.   
The '''Gradient''' filter ('''Advanced''' Properties tab) provides Gradient, Divergence, Vorticity and and Q Criterion.  Here is am example, using disk_out_ref.exo.   
*'''Edit → Reset Session'''.




[[Image:cfd_gradient1.png|1000px]]
[[Image:cfd_gradient1.png|1000px]]






==Probing a fluid==
==Probing a fluid==
There are numerous ways to probe the cells and points of a fluid.  One is with the '''Hover Points On''' and '''Hover Cells On''' icons just above the Renderview.  Another is with the Probe filter.  Here is how to slice and probe a filter.
There are numerous ways to probe the cells and points of a fluid.  One is with the '''Hover Points On''' and '''Hover Cells On''' icons just above the Renderview.  Another is with Interactive Select Cells or Points On.  Then, in the Find Data, turn on Cell or Point Labels.  Yet another is with the Probe filter.  Here is how to use the probe filter.
*'''File → Open → Examples → disk_out_ref.exo.'''.  On the '''Properties''' tab, click '''Apply'''.
*'''File → Open → Examples → disk_out_ref.exo.'''.  On the '''Properties''' tab, click '''Apply'''.
*'''+X'''
*'''+X'''
*'''Filters → Common → Clip'''.  Uncheck '''Show Plane'''.  '''Apply'''.   
*'''Filters → Common → Clip'''.  Uncheck '''Show Plane'''.  Uncheck '''Invert'''.  '''Apply'''.   


The '''Probe''' filter works much better with '''Auto Apply''' turned on.  This is the icon that looks like a tree growing out of a cube.
The '''Probe''' filter works much better with '''Auto Apply''' turned on.  This is the icon that looks like a tree growing out of a cube.
Line 117: Line 196:
*'''Auto Apply''' on
*'''Auto Apply''' on


*'''Filters → Data Analysis → Probe'''.  Now, move over '''disk_out_ref.exo''', updating the probed location with the '''p''' key.
*'''Filters → Data Analysis → Probe'''.  If needed, select the '''RenderView''' window, giving it focus.  Now, move over '''disk_out_ref.exo''', updating the probed location with the '''p''' key.


The '''probed''' data will show in the Spreadsheet view.
The '''probed''' data will show in the Spreadsheet view.
*'''Edit → Reset Session'''.


[[Image:cfd_probe1.png|1000px]]




[[Image:cfd_probe1.png|1000px]]
 
==Animating a static vector field==
*If you have a vector field in your data, you can animate a static dataset.
*Our goal is to create a set of streamlines from a vector field, place points on this set of streamlines, and animate the point down the streamlines.  We will also add glyphs to the streamline points.
*Open disk_out_ref.exo.  '''Apply'''.
*Click the '''-X''' icon.
*'''Stream tracer''' filter.  (We are already streamtracing on V).  Change Seed Type to '''Point Cloud'''.  Optional - change the Opacity to 0.4.  '''Apply'''.
*'''Contour''' filter.  Contour on '''IntegrationTime'''.  '''Apply'''.
*'''Glyph''' filter.  Vectors '''V'''.  No Scale Array.  Scale 1.  Glyph Mode ''' All Points'''.  '''Apply'''.
*View/ Animation View.
*Mode '''Sequence''', No. Frames: '''100'''.
*Change the pulldown box next to the blue '''+''' to be '''Contour'''.
*Click the blue '''+'''.  Note it works better if you use 0 for the start.
*Now, click the play button.  In the pipeline browser, I also turned off visibility for the Contour filter.
 
Lets save this as a movie.
 
* '''File →  Save Animation'''.  Add a file name.  Save as a '''.avi'''.  '''OK'''.  '''OK'''.
 
*'''Edit → Reset Session'''.




[[Image:cfd_animating_static_field.png|1000px]]






==Volume Rendering==
==Volume Rendering==
We are going to paint the fluid by volume rendered temperature.  To give context, we are also going to extract the exterior surface, and clip the disk_out_ref in half.  We will paint this exterior surface black.
*'''File → Open → Examples → disk_out_ref.exo.'''.  On the '''Properties''' tab, click '''Apply'''.
*'''Filters → Extract Surface'''.  '''Apply'''.
*'''Filters → Clip'''.  Deselect '''Invert'''.  '''Apply'''.
*'''Solid Color'''.  Color the clipped surface '''black'''.
*Select '''disk_out_ref.exo''' in the '''Pipeline Browser'''. Paint by '''temp'''.  '''Volume Render'''.  In the '''Color Editor''', change '''presets''' (looks like a folder with a heart) to be '''Black Body Radiation'''.
*'''Edit → Reset Session'''.
[[Image:cfd_volume_rendering.png|1000px]]

Latest revision as of 03:29, 17 December 2021

Visualizing Computational Fluid Dynamics

This tutorial shows common visualization techniques for cfd datasets. We will be using the dataset disk_out_ref.exo, found in Paraview under File/ Open/ Examples. It has a vector field in it called V. Note that we will reset session (i.e., start from scratch) every section.

Slices

  • File → Open → Examples → disk_out_ref.exo.. On the Properties tab, click Apply.
  • +X
  • Filters → Common → Slice. Apply. Unselect the Show Plane.
  • Color by: v.
  • In the pipeline browser, select disk_out_ref.exo
  • Filters → Common → Slice. Y Normal. Apply. Unselect the Show Plane.
  • Color by: pres.
  • View → Color Map Editor → Presets (the little envelope with a heart) → Turbo.
  • With the mouse, rotate the slices around so you can see both surfaces.
  • Edit → Reset Session. There is also a shortcut icon just above where you have been changing colors. It looks like a green counterclockwise snake eating it's tail.


Cfd slices2.png


Stream Tracers - lines and tubes

  • File → Open → Examples → disk_out_ref.exo.. On the Properties tab, click Apply.
  • +X
  • Filters → Common → Stream Tracer. v. Seed Type: Point Cloud. Uncheck Show Sphere. Apply.
  • Color by: v.

Lines don't color as nicely as surfaces. Lets add a tube filter around each streamline.

  • Filters → Search. Type Tube. Apply.

Now, we want to know which directions the particles are moving. We will use a glyph filter. Note we place the glyph filter on the streamline, not the tube.

  • Select StreamTracer in the Pipeline Browser.
  • Filters → Common → Glyph. Glyph Type: Cone. Orientation Array: v. Scale Array: v . Very Important - Scale Factor select the recycle button to the right. Apply.
  • Color by: temp.
  • View → Color Map Editor → Presets (the little envelope with a heart) → Black Body Radiation.

Lets save this really cool image as a screenshot.

  • File → Save Screenshot. Add a file name. OK. OK.
  • Edit → Reset Session.


Cfd streamtracer1.png


Stream Tracers with Custom Source

We want to create stream tracers from any arbitrary source. This can be a line, spline, circle, elipse or any other curving line. An extreme example would be a cylinder cut by a plane.

  • File → Open → Examples → disk_out_ref.exo.. On the Properties tab, click Apply.
  • +X
  • Change vtkBlockColors to Solid Color. Change Opacity to 0.3.
  • Sources → Elipse. Center. 0,0,7. Major Radius Vector, 3,0,0. Ratio, 0.3. Apply.
  • Filters → Search. Type Tube. Apply.
  • Select disk_out_ref.exo in the Pipeline Browser.
  • Filters → Alphabetical → Stream Tracer with Custom Source. Use Elipse as the seed source. Apply.
  • Color by: Solid Color.

The image below is a merging of Stream Tracers with lines and tubes, and Stream Tracer with Custom Source. I have also played with colors to make it look nicer. If interested, replicating is left to the user.

  • Edit → Reset Session.


Cfd streamtracer with custom source.png


Glyphs perpendicular to a slice

  • File → Open → Examples → disk_out_ref.exo.. On the Properties tab, click Apply.
  • +X

Lets create a half slice. This will be used as the seed plane for glyphs.

  • Filters → Common → Slice. Z Normal. Origin 0, 0, 5. Uncheck Show Plane. Apply.
  • Filters → Common → Clip. Uncheck Show Plane. Apply.

Now, apply glyphs.

  • Filters → Common → Glyph. Glyph Type: Arrow. Orientation Array: v. Scale Array: v . Very Important - Scale Factor select the recycle button to the right. .5X. .5X. Apply.
  • Color by: v. Change Magnitude to Z.

Let's put these glyphs back into context by showing the original dataset.

  • Select disk_out_ref.exo in the Pipeline Browser. Representation: wireframe. In the pipeline browser, click on the eyeball next to disk_out_ref.exo. On the Properties tab, change Opacity to 0.3.
  • Use the mouse to zoom into the glyph vectors.
  • Edit → Reset Session.


Cfd slice glyph1.png


Flow in a fluid

To show a velocity profile we need to sample the dataset with a line, and then create glyphs off of this line. This can be done using a trick in ParaView, i.e., the Plot over Line filter. Note that a Resample to Line filter will be added in ParaView 5.11 or so.

  • File → Open → Examples → disk_out_ref.exo.. On the Properties tab, click Apply.

Lets sample over a line.

  • Filters → Data Analysis → Plot over Line. Y Axis. Change the Z component of Point1 and Point2 to 1. Change the Resolution to 40. Apply.
  • Close the LineChartView.
  • In the Pipeline Browser, turn visibility off for disk_out_ref.exo.

We now have a line sampled through the fluid. Lets calculate the negative Z component of V (so it goes the opposite direction on the line from V). That way we can have two profiles, one with V, and one with Vz.

  • Filters → Common → Calculator. Change Result to Vz. Use 0*iHat+0+jHat+-v_Z*kHat for the formula. Apply.

Now we want to create two Glyphs - one from the Calculator filter, and one directly from the Plot over Line filter.

  • The Calculator filter should still be highlighted in the Pipeline Browser.
  • Filters → Common → Glyph. Glyph Type: Arrow. Orientation Array: Vz. Scale Array: Vz . Very Important - Scale Factor select the recycle button to the right. .5X. .5X. Apply.
  • Click on the Color Editor icon. Change the color to Orange. Apply.
  • In the Pipeline Browser select the Plot over Line filter.
  • Filters → Common → Glyph. Glyph Type: Arrow. Orientation Array: v. Scale Array: v . Very Important - Scale Factor select the recycle button to the right. Apply.

Let's put these glyphs back into context by showing the original dataset.

  • Select disk_out_ref.exo in the Pipeline Browser. Click on the eyeball next to disk_out_ref.exo. On the Properties tab, change Opacity to 0.3.

Just to create a nice image, I'm going to split the views horizontally, and show this visualization also from the side.


Cfd fluid velocity profile1.png


You can write the data sampled down the line to a .csv file, where you can post process it with tools such as Excel. Here is how to do it.

  • Select PlotOverLine in the Pipeline Browser.
  • Split screen vertical. Spreadsheet view.
  • Now, click on the Export Scene icon, and write the Spreadsheet down to a .csv file.

Lets save this really cool image as a screenshot.

  • File → Save Screenshot. Add a file name. OK. We want to save both views. Click Save All Views. OK.
  • Edit → Reset Session.


Cfd fluid velocity profile spreadsheet.png


2D plots through a fluid

  • File → Open → Examples → disk_out_ref.exo.. On the Properties tab, click Apply.
  • +X
  • Filters → Data Analysis → Plot over Line. Y Axis. Change the Z component of Point1 and Point2 to 4. Apply.
  • In the Properties Tab, turn all variables off other than v_Z.
  • Click on the RenderView, the left view.
  • Select disk_out_ref.exo in the Pipeline Browser. On the Properties tab, change Opacity to 0.3.
  • Edit → Reset Session.


Cfd 2d plots.png


Contours on a slice

  • File → Open → Examples → disk_out_ref.exo.. On the Properties tab, click Apply.
  • +X
  • Filters → Common → Slice. Uncheck Show Plane. Apply.

We need the magnitude for the Contour filter.

  • Filters → Common → Calculator. Result Array Name vMag. Formula mag(v). Apply.

Now, draw contours on the 2d slice.

  • Filters → Common → Contour. Contour by vMag. Delete the Value, and create a new set using the Add a Range of Values icon. Apply.

A nice visualization is to turn visibility on for Slice and paint by v, and change Contour to be a Solid Color, and make that color White.

Here is an example with additional streamlines, tubes and glyphs.

  • Edit → Reset Session.


Cfd contours on slices.png


Gradient, Divergence, Vorticity and and Q Criterion

The Gradient filter (Advanced Properties tab) provides Gradient, Divergence, Vorticity and and Q Criterion. Here is am example, using disk_out_ref.exo.

  • Edit → Reset Session.


Cfd gradient1.png


Probing a fluid

There are numerous ways to probe the cells and points of a fluid. One is with the Hover Points On and Hover Cells On icons just above the Renderview. Another is with Interactive Select Cells or Points On. Then, in the Find Data, turn on Cell or Point Labels. Yet another is with the Probe filter. Here is how to use the probe filter.

  • File → Open → Examples → disk_out_ref.exo.. On the Properties tab, click Apply.
  • +X
  • Filters → Common → Clip. Uncheck Show Plane. Uncheck Invert. Apply.

The Probe filter works much better with Auto Apply turned on. This is the icon that looks like a tree growing out of a cube.

  • Auto Apply on
  • Filters → Data Analysis → Probe. If needed, select the RenderView window, giving it focus. Now, move over disk_out_ref.exo, updating the probed location with the p key.

The probed data will show in the Spreadsheet view.

  • Edit → Reset Session.


Cfd probe1.png


Animating a static vector field

  • If you have a vector field in your data, you can animate a static dataset.
  • Our goal is to create a set of streamlines from a vector field, place points on this set of streamlines, and animate the point down the streamlines. We will also add glyphs to the streamline points.
  • Open disk_out_ref.exo. Apply.
  • Click the -X icon.
  • Stream tracer filter. (We are already streamtracing on V). Change Seed Type to Point Cloud. Optional - change the Opacity to 0.4. Apply.
  • Contour filter. Contour on IntegrationTime. Apply.
  • Glyph filter. Vectors V. No Scale Array. Scale 1. Glyph Mode All Points. Apply.
  • View/ Animation View.
  • Mode Sequence, No. Frames: 100.
  • Change the pulldown box next to the blue + to be Contour.
  • Click the blue +. Note it works better if you use 0 for the start.
  • Now, click the play button. In the pipeline browser, I also turned off visibility for the Contour filter.

Lets save this as a movie.

  • File → Save Animation. Add a file name. Save as a .avi. OK. OK.
  • Edit → Reset Session.


Cfd animating static field.png


Volume Rendering

We are going to paint the fluid by volume rendered temperature. To give context, we are also going to extract the exterior surface, and clip the disk_out_ref in half. We will paint this exterior surface black.

  • File → Open → Examples → disk_out_ref.exo.. On the Properties tab, click Apply.
  • Filters → Extract Surface. Apply.
  • Filters → Clip. Deselect Invert. Apply.
  • Solid Color. Color the clipped surface black.
  • Select disk_out_ref.exo in the Pipeline Browser. Paint by temp. Volume Render. In the Color Editor, change presets (looks like a folder with a heart) to be Black Body Radiation.
  • Edit → Reset Session.


Cfd volume rendering.png