# Measure exact the alpha.phase 1 level

**URL:** https://discourse.paraview.org/t/measure-exact-the-alpha-phase-1-level/2611
**Category:** ParaView Support
**Created:** [September 24, 2019, 10:04am UTC](https://discourse.paraview.org/t/measure-exact-the-alpha-phase-1-level/2611 "2019-09-24T10:04:36Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Kai\_himself](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kai_himself/32/280_2.png) [@Kai\_himself](https://discourse.paraview.org/u/Kai_himself)
#### Post date: [September 24, 2019, 10:04am UTC](https://discourse.paraview.org/t/measure-exact-the-alpha-phase-1-level/2611/1 "2019-09-24T10:04:36Z")

</div>

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.

 ![Pic_1](https://discourse.paraview.org/uploads/default/original/2X/b/bf7be66e489059e3ec4c811201c9109369a0bddd.jpeg)  
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

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [September 24, 2019, 1:54pm UTC](https://discourse.paraview.org/t/measure-exact-the-alpha-phase-1-level/2611/2 "2019-09-24T13:54:38Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Kai\_himself](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kai_himself/32/280_2.png) [@Kai\_himself](https://discourse.paraview.org/u/Kai_himself)
#### Post date: [September 26, 2019, 5:21pm UTC](https://discourse.paraview.org/t/measure-exact-the-alpha-phase-1-level/2611/3 "2019-09-26T17:21:24Z")

</div>

@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))

```

 ![Volume](https://discourse.paraview.org/uploads/default/original/2X/6/683c22faf7c24d9a487d0efcc50567bd8a5dffc2.jpeg)

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

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

```

 ![High](https://discourse.paraview.org/uploads/default/original/2X/4/4280629a7185d17b946b87ae3d21e1acfbad501c.jpeg)

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.

 ![Cell](https://discourse.paraview.org/uploads/default/original/2X/4/473fb983a8bfbe2d56bfef28df15de57430064c8.jpeg)

Maybe there is a way with less mouseclicks 😉

best regards  
Kai

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [September 26, 2019, 6:06pm UTC](https://discourse.paraview.org/t/measure-exact-the-alpha-phase-1-level/2611/4 "2019-09-26T18:06:58Z")

</div>

> [@Kai\_himself](#):
>
> But if i dont know the groundarea, its possbile to calculate this too ?

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]))`.

> [@Kai\_himself](#):
>
> Maybe there is a way with less mouseclicks 😉

Nope, that’s about the easiest way.

---

<div class="post-metadata">

### Author: ![Kai\_himself](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kai_himself/32/280_2.png) [@Kai\_himself](https://discourse.paraview.org/u/Kai_himself)
#### Post date: [September 26, 2019, 7:05pm UTC](https://discourse.paraview.org/t/measure-exact-the-alpha-phase-1-level/2611/5 "2019-09-26T19:05:50Z")

</div>

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](https://discourse.paraview.org/uploads/default/original/2X/d/d265b0c03d9354097cd0021b7e5a2359cad5e32b.jpeg)

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

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [September 27, 2019, 10:34pm UTC](https://discourse.paraview.org/t/measure-exact-the-alpha-phase-1-level/2611/6 "2019-09-27T22:34:05Z")

</div>

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:

```python
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]`.

---

<div class="post-metadata">

### Author: ![Kai\_himself](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kai_himself/32/280_2.png) [@Kai\_himself](https://discourse.paraview.org/u/Kai_himself)
#### Post date: [September 29, 2019, 6:33pm UTC](https://discourse.paraview.org/t/measure-exact-the-alpha-phase-1-level/2611/8 "2019-09-29T18:33:01Z")

</div>

Thank you very much @cory.quammen

Best regards  
Kai

---

<div class="post-metadata">

### Author: ![Kai\_himself](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kai_himself/32/280_2.png) [@Kai\_himself](https://discourse.paraview.org/u/Kai_himself)
#### Post date: [October 9, 2019, 6:47am UTC](https://discourse.paraview.org/t/measure-exact-the-alpha-phase-1-level/2611/9 "2019-10-09T06:47:51Z")

</div>

I’m not getting this with the **Programmable Filter**

The pipline browser looks like this:

 ![Paraview_1](https://discourse.paraview.org/uploads/default/original/2X/2/27f08f915a45520ba918ec4e1255cb75823e3b16.jpeg)  
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:

 ![error_P](https://discourse.paraview.org/uploads/default/original/2X/a/a4fc4779902cf73f50ea1295fa69d876b6b3afa6.jpeg)

best regards  
Kai

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [October 9, 2019, 1:52pm UTC](https://discourse.paraview.org/t/measure-exact-the-alpha-phase-1-level/2611/10 "2019-10-09T13:52:53Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Kai\_himself](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kai_himself/32/280_2.png) [@Kai\_himself](https://discourse.paraview.org/u/Kai_himself)
#### Post date: [October 10, 2019, 6:01am UTC](https://discourse.paraview.org/t/measure-exact-the-alpha-phase-1-level/2611/11 "2019-10-10T06:01:28Z")

</div>

I’m really sorry I can’t do this. ☹

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

 ![Clip](https://discourse.paraview.org/uploads/default/original/2X/2/2ae2756b19bd112424c29169d1163b6e3c079abe.jpeg)  
Clip was choosen.  
 ![exSurf](https://discourse.paraview.org/uploads/default/original/2X/0/0ff3e668d2431c3207d3e4f8e6d20cbc0d4499e2.jpeg)  
ExtractSelection was choosen.

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

Best regards  
Kai

---

<div class="post-metadata">

### Author: ![Kai\_himself](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kai_himself/32/280_2.png) [@Kai\_himself](https://discourse.paraview.org/u/Kai_himself)
#### Post date: [October 11, 2019, 11:31am UTC](https://discourse.paraview.org/t/measure-exact-the-alpha-phase-1-level/2611/12 "2019-10-11T11:31:23Z")

</div>

Hey @cory.quammen,

i took the liberty of uploading the files.  
Here is the [link](https://we.tl/t-1D3OSGguir). Its a zip file with the simulation (openfoam) and the psvm file. The password is “Paraview” without the ".

Thank you  
Kai

---

<div class="post-metadata">

### Author: ![Kai\_himself](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kai_himself/32/280_2.png) [@Kai\_himself](https://discourse.paraview.org/u/Kai_himself)
#### Post date: [October 14, 2019, 7:10pm UTC](https://discourse.paraview.org/t/measure-exact-the-alpha-phase-1-level/2611/13 "2019-10-14T19:10:36Z")

</div>

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**?
