keep specific patch (boundary) after CleantoGrid filter

Hello,
this might sound as a dumb question, but the situation is the following,
i do simulations in parallel in openfoam, and one of my issues is that when i load the internal mesh data and add transparency to the view, i can see the internal boundaries of the processors. for this reason I beging by using CleantoGrid filter over the openfoam reader. on the other side, sometimes i use the patches that I load on the foam reader, such as for example, inlet. the thing is that obviously after CleantoGrid filter i ‘loss’ the information of the inlet patch, eg., i can not use extract block on CleantoGrid to get the ‘inlet’ boundary.

the only solution i can see right now is to: load the patch, use extractBlock and CleantoGrid on the foam reader, and then use group datasets filter and continue from it with the rest of the paraview script. (this way i can use extractBlock and the display will not show the interface of the processors). i might be overthinking something in the middle, if thats the case, is there a ‘cleanner’ way to get; a source, that has the internalMesh and the boundaries separated AND that if it is in parallel and with opacity!=1 will not show the processors interfaces?
thanks in advance

EDIT: sorry, i see that if I do in the gui of paraview i can still extract the inlet on the CleantoGrid output, so i might be missing something (as i am doing it in python)
my code looks like this:

#open the foam case
simfoam = OpenFOAMReader(registrationName='sim.foam', FileName=casePath, CaseType=CaseType)
simfoam.SkipZeroTime = 0
simfoam.Createcelltopointfiltereddata = 1

#merge the processor boundaries
if simfoam.CaseType=='Decomposed Case':
    nProc=len(glob.glob(casePath+'/processor*'))
    filterForData = CleantoGrid(registrationName='filterWithoutProcBoundaries', Input=simfoam)
else:
    filterForData=simfoam

#load the inlet patch
simfoam.Set(
    MeshRegions=['internalMesh', 'patch/inlet'])

#extract the inlet patch
inlet0 = ExtractBlock(registrationName='ExtractBlock_inlet', Input=filterForData,
                            Selectors = [
                                '/Root/boundary/inlet'
                                ]
                            )

when doing this in pvbatch i get an error, when I do this in the GUI it works, so maybe i am missing something that the trace tool does not show?

Which error ?

sorry i was late and did not full commented.
this is the code:

simfoam = OpenFOAMReader(registrationName=f'{caseFolder}.foam', FileName=casePath, CaseType=CaseType)
simfoam.SkipZeroTime = 0
simfoam.Createcelltopointfiltereddata = 1
animationScene1 = GetAnimationScene()
animationScene1.UpdateAnimationUsingDataTimeSteps()
renderView = GetActiveViewOrCreate('RenderView')
renderView.OrientationAxesVisibility = 0
timeSteps=simfoam.TimestepValues

if simfoam.CaseType=='Decomposed Case':
    nProc=len(glob.glob(casePath+'/processor*'))
    filterForData = CleantoGrid(registrationName='filterWithoutProcBoundaries', Input=simfoam)
    ##filterForData=simfoam   <== line to comment
else:
    filterForData=simfoam

    # load patches
simfoam.Set(
    MeshRegions=['internalMesh', 'patch/inlet'])


inlet0 = ExtractBlock(registrationName='ExtractBlock_inlet', Input=filterForData,
                            Selectors = [
                                '/Root/boundary/inlet'
                                ]
                            )
surfaceNormals0 = SurfaceNormals(registrationName='surfaceNormals0', Input=inlet0, ComputeCellNormals=1)

it is not the extractBlock that gives me issues it is the surfaceNormals0 that gives me actually.
if I run this in the python console of paraview, paraview does not give me any error (in principle) but when i hit the eye of the surfaceNormals0 it crashes completly and i get this error:

critical: In unknown, line 0
critical: Cannot open data file " "" "
error: exception occurred: Segmentation fault

if i uncomment the line ##filterForData=simfoam <== line to comment inside the if ... 'Decomposed Case'
then it does everything correctly (and i can ‘show’ the surfaceNormals0 without paraview crashing.)
if i run this script in pvbatch, in the following lines after i use the normals generated by the filter in a calculator, if i leave the line commented (so i am using the CleantoGrid filter to continue the script, it will throw an error during the calculation), and if i uncomment it, it works without error (the calculator filter)

Are you able to reproduce outside of pvpython, in ParaView GUI ?

yes, in paraview gui, paraview crashes, and I get the error (in the terminal):

critical: In unknown, line 0
critical: Cannot open data file " "" "
error: exception occurred: Segmentation fault

this happends when i try to ‘show’ the surfaceNormals0 filter.
when i do in pvbatch, i dont get an error when doing the surface filter, but when i try to use the normals field generated by it in a calculator filter.
this is in 6.0.0 -RC2

Please share data and steps to reproduce then :slight_smile:

here you have a test case
bubbleColumnEvaporatingDissolvingTest.tar.gz (3.9 MB)
hope it helps. the script is in test.py file

Unable to reproduce so far:

  • File → Open → sim.foam → Decomposed → Apply
  • Filters → CleanToGrid → Apply

hello mathieu,
open paraview GUI, in the python terminal, run script select test.py (one should run the casePath). this will create all the different filters surfaceNormals0 → show (and paraview will close)
where, if you repeat the exact same tree of filters on the GUI (instead of running the script) it will be possible to work normally with surfaceNormals0

So you do not reproduce using the GUI ? But only by running the python script ?

yes, with the python script, using the gui i dont get any error until ‘show’ the last filter where paraview simply crashes. and using the pvbatch, i dont get any error until i try to use the normal field generated by the filter.

I think you misunderstood my question.

Are you able to reproduce the issue without using the python script and by purely creating filters in the GUI ?

If yes, then it’s probably a generic issue.
If not, then it’s probably a python specific issue.

Determining this would be helpful.

BTW I’m unable to reproduce using pvpython either.

my bad, sorry for it, but i mentionned before:

where, if you repeat the exact same tree of filters on the GUI (instead of running the script) it will be possible to work normally with surfaceNormals0

if i do exactly the same but using the GUI only (no python script) and i get exactly the same tree structure as I am getting using the script, it works without issues. thats why i mentionned

so maybe i am missing something that the trace tool does not show?

but not sure what as the two workflows (full GUI or GUI+run script) generates the same dependencies in the tree structure of the pipeline objects.

in pvpython, with the current script (i simplified) you will not get any error as one is not using the normals of the surfaceNormals0 filter.
you can add this filter at the end and pvpython will give an error:

calculatorFlow0 = Calculator(registrationName='calculatorFlow0',AttributeType = 'Cell Data', Input=surfaceNormals0,Function='-1*dot("U.gas","Normals")',ResultArrayName = 'f1O2')

on the other hand if you run the script on the gui (by running it from the terminal) and hit the ‘eye’ icon on the pipeline browser of the surfaceNormals0 filter, paraview at least for me, will crash.

Indeed, I reproduce with the script now.

This is caused by the fact that CleanToGrid outputs a Unstructured Grid, which is not a valid input of the SurfaceNormals filter, which results into an empty output which causes the crash (still a but to crash here).

In any case, just add an ExtractSurface before the SurfaceNormals filter to fix the issue.

1 Like

Thanks, what is extrange is that this step in the gui is not necessary.

It is necessary, you cannot add a SurfaceNormals on the CleanToGrid filter using the GUI, it doesnt let you.

1 Like