CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

Meaning of "fvc::div(phi)"

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree8Likes

Reply
 
LinkBack Thread Tools Display Modes
Old   February 28, 2012, 11:51
Default Meaning of "fvc::div(phi)"
  #1
Member
 
Jeong Kim
Join Date: Feb 2010
Posts: 41
Rep Power: 7
enoch is on a distinguished road
Hi Foamers,

When I look at pEqn.C in the "twoPhaseEulerFoam" solver, I don't really understand the following codes.

.......
for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pEqn
(
fvm::laplacian(Dp, p) == fvc::div(phi)
);
.....

Speaking of div(phi), divergence of any scalar is zero mathematically.

Divergence reduce the order rank of maxtrix.
For an example, let's say, velcotiy vector u=(ux, uy)

div(u)=ux/dx + uy/dy ---> scalar quantity

But, scalar phi=phi(x,y)
div(phi)=0

So what is the meaning of div(phi) and what's a mathematical formulation for the term in openfoam?
enoch is offline   Reply With Quote

Old   July 16, 2013, 04:01
Default
  #2
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Torino, Italy
Posts: 667
Rep Power: 8
sharonyue is on a distinguished road
Hi Kim,

This problem happens to me in the same time!icoFoam's pressure possion equation. Did you find a solution?
sharonyue is offline   Reply With Quote

Old   July 16, 2013, 06:01
Default
  #3
Member
 
Felipe Portela
Join Date: Dec 2012
Location: London
Posts: 58
Rep Power: 4
fportela is on a distinguished road
Isn't phi simply the mass flux rho*U*A ? check this
HTML Code:
http://openfoamwiki.net/index.php/Uguide_table_of_fields
and this
HTML Code:
http://openfoamwiki.net/index.php/Main_FAQ#What_is_the_field_phi_that_the_solver_is_writing
I have not used this particular solver, so I'm not sure what's going on, but from continuity: div(phi) = 0 implies that ddt(rho) is zero, if this is not the case, then div(phi) is not zero.

Cheers,
Felipe
fportela is offline   Reply With Quote

Old   July 16, 2013, 08:31
Default
  #4
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Torino, Italy
Posts: 667
Rep Power: 8
sharonyue is on a distinguished road
Hi Felipre,

Thanks for your prompt reply,
Quote:
Originally Posted by fportela View Post
but from continuity: div(phi) = 0
regarding this, isnt it should be div(u)=0?
sharonyue is offline   Reply With Quote

Old   July 16, 2013, 08:35
Default
  #5
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 12
Bernhard is on a distinguished road
No, because U is the cell centre value, and the divergence is obtained from the face values, i.e. phi.
Bernhard is offline   Reply With Quote

Old   July 16, 2013, 08:38
Default
  #6
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Torino, Italy
Posts: 667
Rep Power: 8
sharonyue is on a distinguished road
Hi Bernhard,
Could you explain more?
sharonyue is offline   Reply With Quote

Old   July 16, 2013, 08:39
Default
  #7
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 12
Bernhard is on a distinguished road
Can you be more specific?
Bernhard is offline   Reply With Quote

Old   July 16, 2013, 08:44
Default
  #8
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Torino, Italy
Posts: 667
Rep Power: 8
sharonyue is on a distinguished road
Quote:
Originally Posted by Bernhard View Post
No, because U is the cell centre value, and the divergence is obtained from the face values, i.e. phi.
I mean all the books say from continuity we have: \nabla \cdot u=0 without mentioning whether its cell centre value or the face value. But Im sure I confused about this. So?
sharonyue is offline   Reply With Quote

Old   July 16, 2013, 08:49
Default
  #9
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 12
Bernhard is on a distinguished road
The book are correct, but is valid without a mesh. If you integrate this equation over a control volume, this converts to a summation over the faces of the velocity times the area ( http://en.wikipedia.org/wiki/Divergence_theorem ). phi is nothing less then the velocity at the face (times the density and the face area).
Bernhard is offline   Reply With Quote

Old   July 16, 2013, 08:51
Default
  #10
Member
 
Felipe Portela
Join Date: Dec 2012
Location: London
Posts: 58
Rep Power: 4
fportela is on a distinguished road
Quote:
Originally Posted by sharonyue View Post
I mean all the books say from continuity we have: \nabla \cdot u=0 without mentioning weather its cell centre value or the face value. But Im sure I confused about this. So?
This is only true for incompressible flow.

For incompressible flow, you have \frac{D\rho}{Dt} = \frac{\partial\rho}{\partial t} + \vec{u} \cdot \nabla (\rho)  = 0

Plug this into continuity

\frac{\partial\rho}{\partial t} + \nabla (\rho \vec{u}) = 0

And you get

\nabla \cdot \vec{u} = 0
fportela is offline   Reply With Quote

Old   July 16, 2013, 09:24
Default
  #11
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Torino, Italy
Posts: 667
Rep Power: 8
sharonyue is on a distinguished road
Quote:
Originally Posted by Bernhard View Post
The book are correct, but is valid without a mesh. If you integrate this equation over a control volume, this converts to a summation over the faces of the velocity times the area ( http://en.wikipedia.org/wiki/Divergence_theorem ). phi is nothing less then the velocity at the face (times the density and the face area).
\int\limits_V^{} {\nabla  \cdot udV}  = \sum\limits_f {{u_f} \cdot {S_f} = 0}

I know this, but phi is a scalar, what is div(scalar).....

Felipe. Yeah, you are right~
sharonyue is offline   Reply With Quote

Old   July 16, 2013, 09:27
Default
  #12
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 12
Bernhard is on a distinguished road
Quote:
Originally Posted by sharonyue View Post
I know this, but phi is a scalar, what is div(scalar).....
Be careful here. phi is a surfaceScalarField, so there is always a direction vector defined by the face area vector.
fportela likes this.
Bernhard is offline   Reply With Quote

Old   July 16, 2013, 09:56
Default
  #13
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Torino, Italy
Posts: 667
Rep Power: 8
sharonyue is on a distinguished road
\int\limits_V^{} {\nabla  \cdot udV}  = \sum\limits_f {{u_f} \cdot {S_f} = 0}

Regarding this, if div(phi)=0 Do you mean:
\int\limits_V^{} {u_f \cdot S_fdV}  = 0
Quote:
phi is a surfaceScalarField, so there is always a direction vector defined by the face area vector
Is there any difference between "surfaceScalarField" and "volScaklaField" expect where they are stored?
sharonyue is offline   Reply With Quote

Old   July 16, 2013, 10:01
Default
  #14
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 12
Bernhard is on a distinguished road
You apply the divergence theorem.
\int\limits_V^{} {\nabla  \cdot udV}  = \int\limits_{\partial V}u\cdot\hat{n}dS =\sum\limits_f {{u_f} \cdot {S_f} = 0}
You can't integrate face values over a volume as you are posting.

The difference between a volScalarField and a surfaceScalarField, is that for a volScalarField, there is a value stored per control volume or cell. For a surfaceScalarField there is a value stored per face.

You can of course interpolate from the one to the other, but this is only accurate to some order.
fportela likes this.
Bernhard is offline   Reply With Quote

Old   July 16, 2013, 10:23
Default
  #15
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Torino, Italy
Posts: 667
Rep Power: 8
sharonyue is on a distinguished road
Quote:
Originally Posted by Bernhard View Post
You apply the divergence theorem.
\int\limits_V^{} {\nabla  \cdot udV}  = \int\limits_{\partial V}u\cdot\hat{n}dS =\sum\limits_f {{u_f} \cdot {S_f} = 0}
You can't integrate face values over a volume as you are posting.

The difference between a volScalarField and a surfaceScalarField, is that for a volScalarField, there is a value stored per control volume or cell. For a surfaceScalarField there is a value stored per face.

You can of course interpolate from the one to the other, but this is only accurate to some order.
Bernhard, Thanks very very much for your consistent help, But I still cannot understand this "div(u)=0" turns into "div(phi)=0" in OpenFOAM, even mathematicly div(vector) works but div(scalar) not.
Does it mean fvc::div(phi)=0 equals to sum(phi)=0 in OpenFOAM? Why doesnt it use sum(phi)=0 instead.
At last,I think I need to clear my head. Thanks for you patience. Really thankful.
sharonyue is offline   Reply With Quote

Old   July 17, 2013, 23:52
Default
  #16
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Torino, Italy
Posts: 667
Rep Power: 8
sharonyue is on a distinguished road
Im still confused!!!!!!

div(u)=0 I know its meaning.

1) If via continuity, we have div(phi)=0, then we make an intergration on this equation like this:

[LaTeX Error: Syntax error]

Is this weird?
Attached Images
File Type: jpg 1.jpg (11.9 KB, 23 views)
sharonyue is offline   Reply With Quote

Old   July 18, 2013, 01:59
Default
  #17
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 12
Bernhard is on a distinguished road
Yes, this is extremely weird. phi only lives in the discretized domain on faces of cells. The is no way you can do a volume integral over such a variable.

Do you know how to derive the equation \nabla\cdot\vec{u}? You can do this using a mass-micro-balanse. This has not yet anything to do with a mesh, but if you understand this, it is easily translated.
Bernhard is offline   Reply With Quote

Old   July 18, 2013, 18:46
Default
  #18
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Torino, Italy
Posts: 667
Rep Power: 8
sharonyue is on a distinguished road
Quote:
Originally Posted by Bernhard View Post
Yes, this is extremely weird. phi only lives in the discretized domain on faces of cells. The is no way you can do a volume integral over such a variable.

Do you know how to derive the equation \nabla\cdot\vec{u}? You can do this using a mass-micro-balanse. This has not yet anything to do with a mesh, but if you understand this, it is easily translated.
Yeah, Im very clear about this \nabla\cdot\vec{u}, and I know after intergral it can be a sum. I dont know whether you know what I dont know.
Code:
fvScalarMatrix pEqn
                (
                    fvm::laplacian(rAU, p) == SUM(phiHbyA)//If there existed "SUM"
                );
Even I can understand this. But I cannot understand fvc::div(phiHbyA).
Anyway thanks bro.


BTW, the unit of fvc::div(u) and fvc::div(phi) is the same:
Code:
fvc::div(HbyA):dimensions      [0 0 -1 0 0 0 0];

internalField   nonuniform List<scalar> 9(0.157469 -0.0674757 -0.487085 -0.960691 0.789192 0.715649 30.1762 0.258981 -30.5822);

fvc::div(phiHbyA):dimensions      [0 0 -1 0 0 0 0];

internalField   nonuniform List<scalar> 9(-0.435688 -0.0982547 0.152804 -0.0448476 0.720155 -0.152663 28.2072 0.236062 -28.5848);
sharonyue is offline   Reply With Quote

Old   July 22, 2013, 04:01
Default
  #19
Member
 
Artem Shaklein
Join Date: Feb 2010
Location: Russia, Izhevsk
Posts: 43
Rep Power: 7
ARTem is on a distinguished road
Take into account that mathematical and OpenFOAM's languages are different.
Originally, mathematical divergence is vector operation that gives you source or sink at a point. When you use finite volume method to discretize differential equation, you get linear form of diff. equation and volumes to store discrete variables. That's why in order to get divergence you should firstly compute fluxes at volume faces.
In OF there are two ways to compute divergence:
1) take fvc::div( of volVectorField ). You can see in sources, it calls for fvc::surfaceIntegrate ( volVectorField & mesh.Sf() ).
2) make first step manually (i.e. phi = U&mesh.Sf()) and call for fvc::div( surfaceScalarField phi ). Again, OF will make fvc::surfaceIntegrate ( surfaceScalarField ).
Mathematically div(scalar phi) has no sense. Because you think of variables as continuous fields, but in OF variables are discrete fields.

You are partially right, there is no "SUM", but "surfaceIntegrate" called by OF to compute div.

And again, phi = U & mesh.Sf(). div(phi) = div(U) = div(U&mesh.Sf()). That's why you get same dimensions.
ARTem is offline   Reply With Quote

Old   August 23, 2013, 00:08
Default
  #20
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Torino, Italy
Posts: 667
Rep Power: 8
sharonyue is on a distinguished road
Quote:
Originally Posted by ARTem View Post
Take into account that mathematical and OpenFOAM's languages are different.
Originally, mathematical divergence is vector operation that gives you source or sink at a point. When you use finite volume method to discretize differential equation, you get linear form of diff. equation and volumes to store discrete variables. That's why in order to get divergence you should firstly compute fluxes at volume faces.
In OF there are two ways to compute divergence:
1) take fvc::div( of volVectorField ). You can see in sources, it calls for fvc::surfaceIntegrate ( volVectorField & mesh.Sf() ).
2) make first step manually (i.e. phi = U&mesh.Sf()) and call for fvc::div( surfaceScalarField phi ). Again, OF will make fvc::surfaceIntegrate ( surfaceScalarField ).
Mathematically div(scalar phi) has no sense. Because you think of variables as continuous fields, but in OF variables are discrete fields.

You are partially right, there is no "SUM", but "surfaceIntegrate" called by OF to compute div.

And again, phi = U & mesh.Sf(). div(phi) = div(U) = div(U&mesh.Sf()). That's why you get same dimensions.
U make it very very clear, Thanks very much. So I just make it a example.:

1. volVectorField U;
fvc::div(U);

2. volVectorField U;
phi = U & mesh.Sf();
fvc::div(phi);

So these two functions are the same rite? fvc::div(u)=fvc::div(phi).

Looks like div() has been overloaded.

I make a testify:

Code:
fvc::div(HbyA)dimensions      [0 0 -1 0 0 0 0];

internalField   nonuniform List<scalar> 9(0.000569046 -8.589e-06 -0.000648869 -0.00128281 0.000183935 0.00124553 0.00416702 3.71583e-06 -0.00422898);

fvc::div(phiHbyA):dimensions      [0 0 -1 0 0 0 0];

internalField   nonuniform List<scalar> 9(0.000569046 -8.589e-06 -0.000648869 -0.00128281 0.000183935 0.00124553 0.00416702 3.71583e-06 -0.00422898);
Its total the same. Good job.

Last edited by sharonyue; August 23, 2013 at 03:35.
sharonyue is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cyclic Boundary creation, what's the meaning of "separationVector" panda60 OpenFOAM 0 June 1, 2010 10:13
What's meaning of UDF FUNCTION zhaoxinyu Fluent UDF and Scheme Programming 0 March 31, 2010 08:04
meaning of residual p-mass ? Dele CFX 0 March 4, 2008 04:23
want to know meaning Sangamesh CD-adapco 0 May 15, 2007 05:15
What's the meaning of "combustion scalar"and.... cfdbeginner CFX 0 November 27, 2003 10:02


All times are GMT -4. The time now is 06:48.