# get fluid velocity in PFV cells

Asked by Christian Jakob on 2013-12-11

Hi,

I am using PFV and want to know how I can get fluid velocity in the cells.
While visualisation in paraview one can see fluid velocities, but how can i get this information in python code?
I tried following codes:

1)
vel = flow.avFlVelOnSph(b.id)

NameError: global name 'avFlVelOnSph' is not defined

Maybe this happens, because I am using an "old" yade version from 16.10.2013 ...?

2)
vel = flow.getCellFlux(flow.getCell(Vector3(xDim/2,yDim/2,zDim/2)))

ERROR /home/christian/YADE/trunk/pkg/dem/FlowEngine.cpp:189 getCellFlux: Getting flux with cond higher than imposedP size.
0.0

Is this just for cells, with imposed pressure?

3)
vel = flow.getBoundaryFlux(0)

This one is working, but I get much smaller values, than in Paraview (factor 1e6!)

christian

## Question information

Language:
English Edit question
Status:
Solved
For:
Assignee:
No assignee Edit question
Solved by:
Christian Jakob
Solved:
2013-12-13
Last query:
2013-12-13
2013-12-11
 Bruno Chareyre (bruno-chareyre) said on 2013-12-11: #1

There is quite a lot of c++ code for PFV that is not reflected on the python side yet.
I suggest to grep Average_Relative_Cell_Velocity to see where is computed in the first place. Everything else is based on this.
You may simply add a new function in order to retrieve this data in python.

Mind that this is the velocity of the fluid relative to the solid. It can look very strange sometimes. A more intuitive quantity is the absolute velocity: local solid velocity + relative velocity.

1) I don't understand why it is "not defined". It should be.
2) getCellFlux is for elements with imposed pressure, yes. It is irrelevant for other elements since, by mass conservation, they would all give flux=0.
3) They are not supposed to be equal, but there should be a relation between them:
boundary flux = velocity.dot(normal) * area #(also maybe multiplied by porosity, not sure now)
From factor 1e6 I would guess your sample size is of the order of 1e-3? Else the must be something wrong somewhere.

Ping me next week if you need more help, I'm a but busy now.

 Christian Jakob (jakob-ifgt) said on 2013-12-11: #2

> There is quite a lot of c++ code for PFV that is not reflected on the python side yet.
> I suggest to grep Average_Relative_Cell_Velocity to see where is computed in the first place. Everything else is based on this.
> You may simply add a new function in order to retrieve this data in python.

ok, i see. back to c++ ...

> 1) I don't understand why it is "not defined". It should be.

bug? do you remember when it got implemented?

> 2) getCellFlux is for elements with imposed pressure, yes. It is irrelevant for other elements since, by mass conservation, > they would all give flux=0.

ok, so it is useless for my purpose.

> 3) They are not supposed to be equal, but there should be a relation between them:
> boundary flux = velocity.dot(normal) * area #(also maybe multiplied by porosity, not sure now)
> From factor 1e6 I would guess your sample size is of the order of 1e-3? Else the must be something wrong somewhere.

right, samples dim = Vector3(.002,.002,.003)

> Ping me next week if you need more help, I'm a but busy now.

thanks for clarification.

 Christian Jakob (jakob-ifgt) said on 2013-12-13: #3

avFlVelOnSph() is working, but it can get nan (one small sphere at a corner of my model was excluded from triangulation I guess). So my solution for getting average fluid velocity (relative to spheres) is:

vel_fluid = 0.0
numspheres=0
for b in O.bodies:
if (b.isStandalone and isinstance(b.shape,Sphere)):
numspheres += 1
vfv = flow.avFlVelOnSph(b.id)
if not isnan(vfv[0]):
vel_fluid += Vector3(vfv[0],vfv[1],vfv[2]).norm()
vel_fluid /= numspheres

hope it helps someone in the future...

christian