Given the new features of the python calculator, it ought not to be difficult
to compute volumes. I would do it iteratively, using an Isovolume between two
different values [min, max]
However, I find that the clipper, or isovolume filter do not seem to always
create consistently oriented cells. By that I mean that some cells are returned
with negative volumes, and that throws off the global computation totally.
the python calculator can let you type in an expression like volume(inputs[0]),
which would compute a cell-by-cell volume (left image in the attached script)
We can also do a global summation like sum(volume(inputs[0])) (right image in
my script)
using well-behaved cuts (such as orthonormal cuts), and flipping the clipper's
normal by toggling "inside out", I do get global volumes that add up to the
full volume = 20^3 = 8000. Anything else with arbitrary cuts (as per my python
scripts) show volumes which do not add up to the global volume, because of the
negative volumes cells. I hope I am not making errors here. Can anyone confirm
my findings about negative volumes?
-----------------
Jean / CSCS
________________________________
From: ParaView [[email protected]] on behalf of Jose Rey
[[email protected]]
Sent: Saturday, October 11, 2014 8:33 AM
To: [email protected]
Subject: [Paraview] Contour volume quantification (volume fractions of a scalar
in an unstructured grid)
Good day,
I would like to calculate the volume contained by each contour surface applied
to an unstructured dataset. How do I do this?
Here is what I have:
1. An 3D unstructured grid resulting from a CFD code (OpenFOAM) with velocities
(Ux, Uy, Uz)
2. Applied the "Calculator" filter to calculate Result Array = Umagnitude from
the point data with the formula (U_X^2+U_Y^2+U_Z^2)^.5
(I used point data for the calculator because I can only apply contour to
point data)
3. Applied the "Contour" filter, and generated 11 volumetric contours (from 0.0
to 0.3 m/s)
Here is where I am stuck (and what I intend):
*. Trying to calculate the volume inside each contour surface
The reason I want to calculate this:
* To calculate a distribution of velocity magnitudes (where the X axis is
velocity magnitude ranges /bins, and Y axis is total volume occupied by the
cells in each velocity magnitude range -- not cell count as is the case of
histograms)
My Paraview version:
* 4.2 running on Win64
(I also have aversion of paraview 4.1 modified to work with OpenFOAM, and
installed in a Ubuntu64x-12.04 virtual box)
Thank you very much in advance,
Jose
--
Jose I. Rey
[email protected]<mailto:[email protected]>
# state file generated using paraview version 4.2.0
# ----------------------------------------------------------------
# setup views used in the visualization
# ----------------------------------------------------------------
#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
# Create a new 'Render View'
renderView1 = GetActiveViewOrCreate('RenderView')
renderView1.ViewSize = [542, 767]
renderView1.CameraPosition = [18.80126864297965, 64.64858146489019, 64.30256227620578]
renderView1.CameraViewUp = [0.19654727882427095, 0.6621268466674191, -0.7231578016650546]
renderView1.CameraParallelScale = 24.51075589308725
renderView1.Background = [0.32, 0.34, 0.43]
# Create a new 'Render View'
renderView2 = CreateView('RenderView')
renderView2.ViewSize = [542, 767]
renderView2.CameraPosition = [18.80126864297965, 64.64858146489019, 64.30256227620578]
renderView2.CameraViewUp = [0.19654727882427095, 0.6621268466674191, -0.7231578016650546]
renderView2.CameraParallelScale = 24.51075589308725
renderView2.Background = [0.32, 0.34, 0.43]
# ----------------------------------------------------------------
# setup the data processing pipelines
# ----------------------------------------------------------------
# create a new 'Wavelet'
wavelet1 = Wavelet()
wavelet1.WholeExtent =[-10,10,-10,10,-10,10]
# create a new 'Clip'
clip1 = Clip(Input=wavelet1)
clip1.ClipType = 'Plane'
clip1.Scalars = ['POINTS', 'RTData']
clip1.Value = 157.0909652709961
clip1.ClipType.Origin = [-4.755335345632526, -4.795472149771396, 1.8378448877017628]
clip1.ClipType.Normal = [0.5492650250422241, -0.8258352593647371, 0.12768733944813251]
# create a new 'Python Calculator'
pythonCalculator1 = PythonCalculator(Input=clip1)
pythonCalculator1.Expression = 'volume(inputs[0])'
pythonCalculator1.ArrayAssociation = 'Cell Data'
pythonCalculator1.ArrayName = 'cell_vol'
pythonCalculator1.CopyArrays = 0
# create a new 'Python Calculator'
pythonCalculator2 = PythonCalculator(Input=clip1)
pythonCalculator2.Expression = 'sum(volume(inputs[0]))'
pythonCalculator2.ArrayAssociation = 'Cell Data'
pythonCalculator2.ArrayName = 'total_vol'
pythonCalculator2.CopyArrays = 0
# ----------------------------------------------------------------
# setup color maps and opacity mapes used in the visualization
# note: the Get..() functions create a new object, if needed
# ----------------------------------------------------------------
# get color transfer function/color map for 'cellvol'
cellvolLUT = GetColorTransferFunction('cellvol')
cellvolLUT.RGBPoints = [-1.0, 0.231373, 0.298039, 0.752941, 0.0, 0.865003, 0.865003, 0.865003, 1.0, 0.705882, 0.0156863, 0.14902]
cellvolLUT.ScalarRangeInitialized = 1.0
# get opacity transfer function/opacity map for 'cellvol'
cellvolPWF = GetOpacityTransferFunction('cellvol')
cellvolPWF.Points = [1.0, 0.0, 0.5, 0.0, 2.0, 1.0, 0.5, 0.0]
cellvolPWF.ScalarRangeInitialized = 1
# get color transfer function/color map for 'totalvol'
totalvolLUT = GetColorTransferFunction('totalvol')
totalvolLUT.RGBPoints = [1901.6661546091013, 0.231373, 0.298039, 0.752941, 1902.1661546091013, 0.865003, 0.865003, 0.865003, 1902.6661546091013, 0.705882, 0.0156863, 0.14902]
totalvolLUT.ScalarRangeInitialized = 1.0
# get opacity transfer function/opacity map for 'totalvol'
totalvolPWF = GetOpacityTransferFunction('totalvol')
totalvolPWF.Points = [2000.0, 0.0, 0.5, 0.0, 2001.0, 1.0, 0.5, 0.0]
totalvolPWF.ScalarRangeInitialized = 1
# ----------------------------------------------------------------
# setup the visualization in view 'renderView1'
# ----------------------------------------------------------------
# show data from wavelet1
wavelet1Display = Show(wavelet1, renderView1)
# trace defaults for the display properties.
wavelet1Display.Representation = 'Outline'
wavelet1Display.ColorArrayName = ['POINTS', '']
wavelet1Display.ScalarOpacityUnitDistance = 1.7320508075688779
wavelet1Display.Slice = 10
# show data from pythonCalculator1
pythonCalculator1Display = Show(pythonCalculator1, renderView1)
# trace defaults for the display properties.
pythonCalculator1Display.ColorArrayName = ['CELLS', 'cell_vol']
pythonCalculator1Display.LookupTable = cellvolLUT
pythonCalculator1Display.ScalarOpacityUnitDistance = 1.5888006740798355
# show color legend
pythonCalculator1Display.SetScalarBarVisibility(renderView1, True)
# setup the color legend parameters for each legend in this view
# get color legend/bar for cellvolLUT in view renderView1
cellvolLUTColorBar = GetScalarBar(cellvolLUT, renderView1)
cellvolLUTColorBar.Position = [0.45470425138632165, 0.05708877284595293]
cellvolLUTColorBar.Position2 = [0.42999999999999994, 0.1200000000000001]
cellvolLUTColorBar.Orientation = 'Horizontal'
cellvolLUTColorBar.Title = 'cell_vol'
cellvolLUTColorBar.ComponentTitle = ''
# ----------------------------------------------------------------
# setup the visualization in view 'renderView2'
# ----------------------------------------------------------------
# show data from wavelet1
wavelet1Display_1 = Show(wavelet1, renderView2)
# trace defaults for the display properties.
wavelet1Display_1.Representation = 'Outline'
wavelet1Display_1.ColorArrayName = ['POINTS', '']
wavelet1Display_1.ScalarOpacityUnitDistance = 1.7320508075688779
wavelet1Display_1.Slice = 10
# show data from pythonCalculator2
pythonCalculator2Display = Show(pythonCalculator2, renderView2)
# trace defaults for the display properties.
pythonCalculator2Display.ColorArrayName = ['CELLS', 'total_vol']
pythonCalculator2Display.LookupTable = totalvolLUT
pythonCalculator2Display.ScalarOpacityUnitDistance = 2.279731197052923
# show color legend
pythonCalculator2Display.SetScalarBarVisibility(renderView2, True)
# setup the color legend parameters for each legend in this view
# get color legend/bar for totalvolLUT in view renderView2
totalvolLUTColorBar = GetScalarBar(totalvolLUT, renderView2)
totalvolLUTColorBar.Title = 'total_vol'
totalvolLUTColorBar.ComponentTitle = ''
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the ParaView Wiki at:
http://paraview.org/Wiki/ParaView
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview