CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   local courant number (

psosnows April 30, 2009 08:51

local courant number

I would like to find out what is the local courant number in my computational domain.

The CoNum calculated by supported functions uses the surface scalar field phi, calculates the value for each face and outputs the max and mean value.

My idea was in general:
- create volScalarField vsfCoNum and use it as output
- in each time step:
- - calculate surfaceScalarField surfCoNum
- - for each cell in vsfCoNum
- - - find cell`s faces
- - - assign max value of surfCoNum of those found faces to vsfCoNum

I tried to implement it like this:

void incompressibleCourantNo
const volScalarField &vsfCoNum,
const fvMesh &mesh,
const Time &runTime,
const surfaceScalarField &phi
surfaceScalarField SfUfbyDelta =

surfaceScalarField CoNumSurfField (
(SfUfbyDelta/mesh.magSf()) * runTime.deltaT().value()

forAll(vsfCoNum, cell){
vsfCoNum[cell] = (...)


Unfortunately the assigment CoNum[cell] = (...) announces that this is "assignment for read only location". The same was with CoNum.internalField()[cell] = (...).

I know that there is some easy way to set the value at certain cell but I simply have problem with finding it.

Could you Foamers help me?


mecbe2002 May 13, 2010 09:57

Hi Pawel,

Are you able to calculate Local Courant no? If so can you post the code?

I also want to do the same.


psosnows May 13, 2010 13:01

Unfortunately I cannot find the code… Since some time I did not touch OF directly, and my data are a bit in a mess…
But I am sure that I finally managed to use the idea that I described almost a year ago.
The problem was to get to the data that you need, that is while having a cell number, find the faces that are “building “ that cell. But after some attempts it was possible. The code from last year points to some invalid data, you have to find another way to get the faces corresponding to a cell.

mecbe2002 May 14, 2010 01:58


Thanks for the reply.
I will work on it.


All times are GMT -4. The time now is 02:26.