Measure exact the alpha.phase 1 level

Hey Forum,
is it possible to measure automatically the distance from the bottom to the alpha.phase 1 level end ?
I want to get the relationship between h (heigt) and Q (flux), h(Q), therefor i need a good measurment of the waterlevel.
Below is a picture of my system.


Its a very coarse Mesh, it will get finer. My idea is, to sum up the cell high where the alpha.phase1 >= 0.8 for example, is it possible ?

Best regards
Kai

Sure, you can sum up the cell volume where alpha.phase1 >-= 0.8. You can use a Python Annotation filter and set the Expression to something like

sum(volume(inputs[0]) * (alpha.phase1 >= 0.8))

volume computes the cell volumes for each cell, alpha.phase1 >= 0.8 produces a 1 where the threshold criterion is met and 0 otherwise, and sum adds up all the cell volumes.

Dividing the volume by the surface area should give you the height.

1 Like

@cory.quammen,
thank you for your answer, and sorry for my late reply.
With this expression i get the volume where the AP.1 is over or similar to 0.8.

sum(volume(inputs[0]) * (alphaphase1 >= 0.8))

if i divide it with the width and length, i get the high.

sum(volume(inputs[0]) * (alphaphase1 >= 0.8))/(5*5)

But if i dont know the groundarea, its possbile to calculate this too ?

And a little offtopic question. I marked one cell at the front surface, can i get a few information about the marked cell e. g. length in x, y, and z direction ?

aunt edit:
I think i finde a way to display the cell dimensions. I extract the selection (one Cell) and then the information is displayed.

Maybe there is a way with less mouseclicks :wink:

best regards
Kai

Sure. You can first use Extract Surface filter to get just the surface of your domain. From that select the cells representing the ground using the cell selection tools (the tiny icons above the render view). Finally, extract those cells with an Extract Selection filter, then add a Python Annotation with the expression sum(area(inputs[0])).

Nope, that’s about the easiest way.

1 Like

Thank you very much !

"Area: " + format(sum(area(inputs[0])), '.2f')

and
"A.P1 high: " + format(sum(volume(inputs[0]) * (alphaphase1 >= 0.8)/ 24.82),'.2f')

high

If i may ask one more question, is it possible to assign the area to a variable like
A = sum(area(inputs[0]))

Thank you very much @cory.quammen

Instead of Python Annotation only, you can use Programmable Filter to compute both volume and surface area from the full and extracted dataset.

First, click the original dataset in the Pipeline Browser, then Ctrl-click the Extract Surface Filter, so you have two selected filters in the browser. Now add a Programmable Filter with the following script:

from paraview import vtk

height = sum(volume(inputs[0]) * (alphaphase1 >= 0.8)) / sum(area(inputs[1]))
output.FieldData.append(height, "height") 

Finally, add a Python Annotation with Array Association set to “Field Data” and Expression set to height[0].

1 Like

Thank you very much @cory.quammen

Best regards
Kai

I’m not getting this with the Programmable Filter

The pipline browser looks like this:


With an ExtractSelection at the bottom, and a blue rectangle.
I write your script in the ProgrammableFilter, but i got this error message:

NameError: global name 'alphaphase1' is not defined
Traceback (most recent call last):
File "<stron>", line 24, in <modul>
File"<strin>" line 4, un RequestData

if i tried the script, without the * (alphaphase1 >= 0.8), i got no error at this point.
Then the error comes along with the PythonAnnotation, i got a hugh error message:

best regards
Kai

From the Pipeline Browser, it looks like one input is the Extract Selection filter and the other input is Extract Surface. That second input should be the Clip4 filter instead of Extract Surface, assuming that is the volume you want to process.

1 Like

I’m really sorry I can’t do this. :frowning:

I think i choose the right filter in the pipeline browser.


Clip was choosen.

ExtractSelection was choosen.

MAy should I just send you my openFoam simulation? And you look into it ?

Best regards
Kai

Hey @cory.quammen,

i took the liberty of uploading the files.
Here is the link. Its a zip file with the simulation (openfoam) and the psvm file. The password is “Paraview” without the ".

Thank you
Kai

I have to change the Output Data Set Type to vtkUnstructuredGrid
but the expression (alphaphase1 >= 0.8) still dont work.
I cant finde the alphaphase1 comand, in the Guide at side 258 ff., is it even possible to filter the alphaphase with the ProgrammableFilter ?