CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   solve equation (

DiegoNaval November 30, 2010 12:09

solve equation
Hi all,
I have a stupid question but I don't find the solution.
I must solve the following equation:
U & grad(eta) - Uz=0
where eta is a scalar field and U is velocity vector and Uz is the z-component of U.

How can I write the scalar matrix etaEqn and solve it?


santiagomarquezd November 30, 2010 13:08

Hi, Is your U field divergence free [div(U)==0]???, in this case you have

U & grad(eta) - Uz=0 -> div(U eta)-Uz=0

so that in FOAM


where phi is previously defined as phi=U&Sf, like is scalarTransportFoam, icoFoam, etc.


santiagomarquezd November 30, 2010 13:15

One more thing, Is your equation dimensionally consistent?


DiegoNaval November 30, 2010 14:45

Thank you Santiago Marquez Damian
I solve like you suggest and it works.
Info<<"Inizio calcolo Matrice Eta"<<endl;
faScalarMatrix etaEqn
Info<<"Inizio Relax"<<endl;
Info<<"Inizio Solve"<<endl;
solve(etaEqn == (Us & aMesh.faceAreaNormals()));

Dimensionally is consistent because eta is a areaSaclarField and U is a areaVectorField.
But now I have an other problem, I use as linear solver the
eta smoothSolver
smoother DILU;
tolerance 1e-06;
relTol 0;
and as boundary condition:
type fixedValue;
value uniform 0;
type zeroGradient;
type zeroGradient;
type zeroGradient;
but after few iteration the solution explode, do you think I make some macroscopical error? I use also a relax factor of 0.3 for the etaEqn.


santiagomarquezd November 30, 2010 14:59

I don't know, may be you can post the console output at the exploding moment and some data about the physical problem.


DiegoNaval November 30, 2010 16:46

I find the problem is the div shemes, I use a Gauss Linear and all explode, than I change in a Upwind and all works fine!!!

Thank for the help.

All times are GMT -4. The time now is 08:07.