CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   problem when decomposing the velocity flux according to the x, y and z directions.. (http://www.cfd-online.com/Forums/openfoam-programming-development/84234-problem-when-decomposing-velocity-flux-according-x-y-z-directions.html)

 Cyp January 24, 2011 06:48

[solved]problem when decomposing velocity flux according to the x, y and z directions

Hi!

I would like to decompose the velocity flux phi into 3 flux, one for each direction:

Code:

`phi = phi_x + phi_y + phi_z`
To do that, I defined phi_x, phi_y and phi_z as:
Code:

```surfaceScalarField phi_x = linearInterpolate(U.component(vector::X)*vector(1,0,0)) & mesh.Sf(); surfaceScalarField phi_y = linearInterpolate(U.component(vector::Y)*vector(0,1,0)) & mesh.Sf(); surfaceScalarField phi_z = linearInterpolate(U.component(vector::Z)*vector(0,0,1)) & mesh.Sf();```
Then I update these fields at each time step with the above definition. However, the field
Code:

`phiTest = phi - (phi_x+phi_y+phi_z)`
is not equal to "zero". Which (I suppose) yields in divergence for my applications...

Is someone know how to do such a thing ?

I was wondering is there is a way to get these fields from the fvScalarMatrix pEqn exactly in the same manner we update the phi flux field :
In OpenFOAM, we get the phi flux from the pEqn matrix:
Code:

```fvScalarMatrix pEqn (     fvm::laplacian(-M,p) ); pEqn.setReference (....); pEqn.solve(); phi = pEqn.flux();```
I was wondering is there is a way to get these fields (phi_x, phi_y, phi_z) from the fvScalarMatrix pEqn in similar manner ??

Best regards,
Cyp

PS: in my example, M is a volTensorField

 Cyp January 24, 2011 15:46

I found a solution : from phi = pEqn.flux() I can create phix, phiy and phiz.

First, I defined a flux phi_ex with 1 on the faces concerning x and 0 elsewhere. I can create this flux with this snippet:

Code:

```    volVectorField E     (         IOobject         (             "E",             runTime.timeName(),             mesh,             IOobject::NO_READ,             IOobject::AUTO_WRITE         ),         mesh,       dimensionedVector ("E",dimensionSet(0,0,0,0,0),vector::zero)     );     E = vector(1,0,0);     surfaceScalarField phi_ex = linearInterpolate(E) & mesh.Sf() / mesh.magSf();```
then I can get phix from phi using :
Code:

`phix = phi * phi_ex;`
And I repeat the operation for y and z.

However, I still have problem on my outlet BC....

 All times are GMT -4. The time now is 05:54.