CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   Questions for the bdivb function in OpenFOAM (

gkang May 11, 2006 13:50

Hi, all I have a question f
Hi, all

I have a question for 'div' function in OpenFOAM. I am solving advection-diffusion equation and the advection term has a velocity that is a vector. I can't use 'div' in OpenFOAM for solving 'div(U,C) here U is the velocity(vector) and C is concentration(scalar) in 2D. There is also another velocity applying to advection term, 'div(V,C), here V is a constant velocity and C is same as above. I can't use 'div' for this either. I tried 'V * div(C)' but it didn't work. Hence, what I did was:

volVectorField gradC = fvc::grad(C);
volScalarField gradCx = gradC.component(0);
volScalarField gradCy = gradC.component(1);

volVectorField gradUx = fvc::grad(U.component(0));
volScalarField gradUxx = gradUx.component(0);

volVectorField gradUy = fvc::grad(U.component(1));
volScalarField gradUyy = gradUy.component(1);

gradUxx*C+U.component(0)*gradCx + gradUyy*C+U.component(1)*gradCy + V*(gradCx+gradCy)

By the way, U is given volVectorField from other case and I used the one of identities in page 21 of Programmer's Guide to solve 'div'.

It worked fine but for the mathematic sense it is a bit strange. Are there any other ways to do this?

pierre May 11, 2006 15:31

I guess you could try, fvVect
I guess you could try,
fvVectorMatrix CEqn
+ fvm::div(phi, C)
- fvm::laplacian(Coef, C)
for the concentration scalar,
where "phi" is the flux through the cell faces, calculated from velocity field obtained either solving for U or from a fixed velocity field (look at icofoam for example for the former) and "Coef" a diffusion coeffecient of your choice.
i.e. I guess fvm::div(flux, vector) or fvm::div(flux, scalar) is the right notation.


pierre May 11, 2006 15:33

Oops mistake sorry it is fvSc
Oops mistake sorry it is
fvScalarMatrix CEqn
+ fvm::div(phi, C)
- fvm::laplacian(Coef, C)


gkang May 13, 2006 11:11

Dear Pierre Thanks for your
Dear Pierre

Thanks for your advices. I tried flux instead of velocity and it worked fine. The result was much smoother and nicer. In the previous one there were some truncation errors (I guess) but there are not now.
I am doing further development at the moment and I will put some questions here if anything arise.


All times are GMT -4. The time now is 04:58.