How to extract surface area from unstructured grid

Hi,
I’m working on an unstructured grid layout: the scalars on the coordinates represent some high current densities in the mesh. I’ve created a tiny script that extract all the points with current density above a defined threshold and now I have a set of isolated spots in the mesh I need to further process.
I do need to extract the total area of each spot (I call them islands) and write it somewhere in a file, or if possible change the color on the screen for those spots.
Any suggestion on how to do that? Here’s my code:
from paraview.simple import *
import sys
reader = LegacyVTKReader(FileNames=[str(sys.argv[1])])
Show(reader)
thresholdFilter = Threshold(reader)
thresholdFilter.Scalars
thresholdFilter.ThresholdRange
thresholdFilter.ThresholdRange = [2.77e09, 2e10]
Hide(reader)
Show(thresholdFilter)
dp2 = GetDisplayProperties(thresholdFilter)
thresholdFilter.PointData[:]
hotSpots = thresholdFilter.PointData[0]
hotSpots.GetRange()

scalars_PVLookupTable = GetColorTransferFunction(“scalars”)
scalars_PVLookupTable.ApplyPreset(‘jet’, True)
ScalarBarWidgetRepresentation1 = CreateScalarBar( Title=“scalars”, LabelFontSize=12, Enabled=1, LookupTable=scalars_PVLookupTable, TitleFontSize=12 )
GetRenderView().Representations.append(ScalarBarWidgetRepresentation1)

Thanks in advance
Fabio

Some filters to try that could help you do this.

Connectivity - to identify the islands via the “RegionID” arrays.

Threshold - to pull out individual islands

Extract Surface - to pull out the skin so that you can measure area rather than volume.

Integrate Variables - to sum up the area/(volume) of all of the individual cells.

Hi Dave,

Thanks for the tips! I was able to (I think) implement your suggestions. The problem I still see though is that the integrateVariables is just showing (once I switch view to SpreadSheet) one line with a single point ID and a single RegionID,
although in the rendered view I can see all my islands as expected.

What am I missing?

Thanks again for all the suggestions!

from paraview.simple import *

import sys

#reader = LegacyVTKReader(FileNames=[str(sys.argv[1])])

reader = LegacyVTKReader(FileNames=[“Current_density-m3-mag-xyz_slice.vtk”])

Show(reader)

connectivity1 = Connectivity(Input=reader)

Hide(reader)

Show(connectivity1)

##dp1 = GetDisplayProperties(reader)

##dp1.Representation(‘Wireframe’)

thresholdFilter = Threshold(Input=connectivity1)

#thresholdFilter = Threshold(reader)

thresholdFilter.Scalars = “scalars”

#thresholdFilter.ThresholdRange

thresholdFilter.ThresholdRange = [2.77e09, 2e10]

##thresholdFilter.ThresholdRange = [3.5e09, 2e10]

#Hide(reader)

Hide(connectivity1)

Show(thresholdFilter)

dp2 = GetDisplayProperties(thresholdFilter)

thresholdFilter.PointData[:]

hotSpots = thresholdFilter.PointData[0]

range = hotSpots.GetRange()

scalars_PVLookupTable = GetColorTransferFunction(“scalars”)

scalars_PVLookupTable.RescaleTransferFunction(range[0], range[1])

scalars_PVLookupTable.ApplyPreset(‘jet’, True)

ScalarBarWidgetRepresentation1 = CreateScalarBar( Title=“scalars”, LabelFontSize=12, Enabled=1, LookupTable=scalars_PVLookupTable, TitleFontSize=12 )

GetRenderView().Representations.append(ScalarBarWidgetRepresentation1)

extractSurface1 = ExtractSurface(Input=thresholdFilter)

get display properties

#extractSurface1Display = GetDisplayProperties(extractSurface1, view=renderView2)

extractSurface1Display = GetDisplayProperties(extractSurface1)

set scalar coloring

ColorBy(extractSurface1Display, (‘POINTS’, ‘scalars’))

get color transfer function/color map for ‘RegionId’

regionIdLUT = GetColorTransferFunction(‘RegionId’)

Hide the scalar bar for this color map if no visible data is colored by it.

#HideScalarBarIfNotNeeded(regionIdLUT, renderView2)

HideScalarBarIfNotNeeded(regionIdLUT)

rescale color and/or opacity maps used to include current data range

extractSurface1Display.RescaleTransferFunctionToDataRange(True, False)

show color bar/color legend

#extractSurface1Display.SetScalarBarVisibility(renderView2, True)

get color transfer function/color map for ‘scalars’

scalarsLUT = GetColorTransferFunction(‘scalars’)

get opacity transfer function/opacity map for ‘scalars’

scalarsPWF = GetOpacityTransferFunction(‘scalars’)

extractSurface1.Input.Scalars = “scalars”

Hide(thresholdFilter)

Show(extractSurface1)

integrate = IntegrateVariables(Input=extractSurface1)

I’m guessing it is the threshold filter. Make sure the array your threshold on is the island id and that you select just one island. Then you will have to iterate over all of the islands, getting the area of each one in turn.