CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   compute courant number for 3D geometry (

saeid.oqaz September 25, 2012 06:44

compute courant number for 3D geometry
hi foamers.
i have 2 question about coutant number. in 3D geometry coutanr number calcualte as follows for any cell : ux.deltaT/deltax + uy.deltaT/deltay + uz.deltaT/deltaz
does openfoam calculate co number same this formula?
i read courantNo.H file and didnt understand about how calculate openfaom co number.

next question : in my case courant number very little (in order e-16). why?

meindert September 25, 2012 08:57

Hi Saeid,

OpenFOAM does something very similar to your approach.


00037    scalarField sumPhi
00038    (
00039        fvc::surfaceSum(mag(phi))().internalField()
00040    );
00042    CoNum = 0.5*gMax(sumPhi/mesh.V().field())*runTime.deltaTValue();

My understanding of this piece of code is that for each cell it sums the face flux magnitudes, divides it by the cell volume and multiplies it with deltaT/2. The maximum over all cells is then the Courant number.
If you write it out, you will get exactly what you wrote in your post, with twice the amount of terms. I am not entirely sure about the factor 1/2, but my guess is that it has something to do with the fact that you get twice the amount terms.

I hope this helps.

saeid.oqaz September 25, 2012 13:37

the code you say for openfoam 2.1 . i use openFOAM ext.1-6. and i work on incompressible flow. in directory src / finiteVolume / cfdTools / incompressible / CourantNo.H

code :

PHP Code:

33 scalar CoNum 0.0;
34 scalar meanCoNum 0.0;
35 scalar velMag 0.0;
if (mesh.nInternalFaces())
38 {
39     surfaceScalarField magPhi mag(phi);
  41     surfaceScalarField SfUfbyDelta 
42         mesh.surfaceInterpolation::deltaCoeffs()*magPhi;
  44     CoNum 
45         .value()*runTime.deltaT().value();
  47     meanCoNum 
= (sum(SfUfbyDelta)/sum(mesh.magSf()))
48         .value()*runTime.deltaT().value();
  50     velMag 
51 }
  53 Info
<< "Courant Number mean: " << meanCoNum
<< " max: " << CoNum
<< " velocity magnitude: " << velMag
<< endl

i dont understand openfaom how calculate co number. for example SfUfbyDelta how cumpute?

thanks for replying me.

meindert September 25, 2012 13:52

I'm not familiar with that version of OpenFOAM, but the implementation is not very different actually. deltaCoeffs() returns 1/[distance between owner cell center and neighbour cell center]. I think you should be able to figure out the rest for yourself.

meindert September 25, 2012 14:54

I'm sorry, I was in a hurry. The implementation in OpenFOAM-1.6-ext is different. It finds the maximum over all faces and uses it to calculate the Courant number.

So this is what it does:
- calculate [face flux magnitude]/([distance from owner cell center to neighbour cell center]*[face area])
- take maximum over all faces and multiply the resulting value with deltaT

saeid.oqaz September 25, 2012 16:55

hi Meindert

youe explanation was perfect and help me alot. thanks very much.

All times are GMT -4. The time now is 09:29.